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
Venkateswarlu PVenkateswarlu P 

Test class for Map

public class Map_Accounts {   
    public Map<Id,Account> accMap        {set;get;}
    public List<Account> accList         {set;get;}
    public Account a                    {set;get;}    
    // Constructor
    public Map_Accounts(){
        accMap = new Map<id,Account>();         
        accList=[Select Id, Name from Account limit 5];
        accMap.putAll(accList);
              
        for (Id idKeys : accMap.keySet()){
            a = accMap.get(idKeys);
        }        
    }  
}
Best Answer chosen by Venkateswarlu P
sfdcMonkey.comsfdcMonkey.com
Hi try below test class for 100% coverge
@isTest
private class testClass{
    static testMethod void TestCls(){ 
        account acc = new account();
          acc.Name = 'test';
         // add all required fields here
        insert acc;
        
	  Map_Accounts mapAcc = new Map_Accounts();
        
    }
}
Thanks let us know if it helps you