You need to sign in to do that
Don't have an account?
Mukul
Test Case for a Constructor
Hi all,
Can anyone help me out in writing a unit test for constructor method? I am very new to writing test methods. Please help!!
Here is the snippet of the controller constructor code:
// Constructor Method public newScoreRuleController () { // Give me blank lines of my Object ScoringRule = new List<ScoringRule__c>(); for (integer i = 0; i < 5; i++) { ScoringRule.add( new ScoringRule__c() ); } }
Thanks in advance!
Regards
Mukul
Something like (untested) :
static testMethod void testConstructor() { newScoreRuleController scc = new newScoreRuleController(); //checking if we have 5 objects in the List System.assertEquals(scc.getScoringRule().size(), 5); }
All Answers
Hi Mattdarnold,
Thanks for replying.
This is how i access ScoringRUle:
public List<ScoringRule__c> ScoringRule { get; private set;}
Regards
Mukul
Something like (untested) :
static testMethod void testConstructor() { newScoreRuleController scc = new newScoreRuleController(); //checking if we have 5 objects in the List System.assertEquals(scc.getScoringRule().size(), 5); }
Thanks! That worked!
Regards
Mukul