You need to sign in to do that
Don't have an account?

how to write a testclass for void method using class variables
Hi Experts,
Please tell me how to do below scenario.
I have a controller class which has a method
Class variable.
public map<String,Integer> EmpMap = new map<String, Integer>();
Method Name.
public void saveAllDetails()
{
AddCoreCategories();
AddShrinkageCategories();
AddAvailability();
WeekDuration();
set<String> allKeys = EmpMap.keySet();
list<Integer> allValues = EmpMap.Values();
}
My test class
@isTest
public class AddQAAMWeeklyPlannerTest {
static testmethod void saveAllDetails()
{
AddQAAMWeeklyPlanner obj = new AddQAAMWeeklyPlanner();
obj.saveAllDetails();
}
}
My underlined statements are always gettting failed, pls tell me a way to set value for class variable.
Reagrds
Karthic Sankar V P
Please tell me how to do below scenario.
I have a controller class which has a method
Class variable.
public map<String,Integer> EmpMap = new map<String, Integer>();
Method Name.
public void saveAllDetails()
{
AddCoreCategories();
AddShrinkageCategories();
AddAvailability();
WeekDuration();
set<String> allKeys = EmpMap.keySet();
list<Integer> allValues = EmpMap.Values();
}
My test class
@isTest
public class AddQAAMWeeklyPlannerTest {
static testmethod void saveAllDetails()
{
AddQAAMWeeklyPlanner obj = new AddQAAMWeeklyPlanner();
obj.saveAllDetails();
}
}
My underlined statements are always gettting failed, pls tell me a way to set value for class variable.
Reagrds
Karthic Sankar V P
The test looks fine. I tried this in my org and it gives me 100% code coverage. What error are you seeing at your end?