function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
karthic sankar 9karthic sankar 9 

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
AnudeepAnudeep (Salesforce Developers) 
Hi Karthic, 

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? 

User-added image