You need to sign in to do that
Don't have an account?
Nakata
How can i do a test method for my code ?
Good day,
I always have problem to create test method :(
May i know how can we do the test method for below method
public static void myMethod(List<String> tempCampaignIDList){ if(tempCampaignIDList.size()>0){ List<Campaign> campaignList = [SELECT Id, Type FROM Campaign WHERE id IN :tempCampaignIDList]; for(Campaign cp : campaignList){ if(!CampaignVehicleLookupMap.containsKey(cp.id)){ CampaignVehicleLookupMap.put(cp.id, cp.type); } } } }
Thanks in advance !
Hi Nakata,
If you are new to Force.com platform, I'd recommend reading this introduction to Test Methods article:
http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods
In this instance, I'd suggest the following steps:
1. Create test data - create and insert some test campaigns and add their ids to a list
2. Test the method - call the 'myMethod' with the list created above
3. Check the value in the 'CampaignVehicleLookupMap' using either System.Assert or System.AssertEquals method.
Regards,
A J
All Answers
Hi Nakata,
If you are new to Force.com platform, I'd recommend reading this introduction to Test Methods article:
http://wiki.developerforce.com/index.php/An_Introduction_to_Apex_Code_Test_Methods
In this instance, I'd suggest the following steps:
1. Create test data - create and insert some test campaigns and add their ids to a list
2. Test the method - call the 'myMethod' with the list created above
3. Check the value in the 'CampaignVehicleLookupMap' using either System.Assert or System.AssertEquals method.
Regards,
A J
How come the test methods consumes Autonumbers from an autonumber column? Why is this not fixed by salesforce?
~NK