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
Shubhangi JadhavShubhangi Jadhav 

Can anyone tell me how to cover these two lines in test class:

Can anyone tell me how to cover these two lines in test class:

for(id conId:mapContactPrimary.keyset())                 {                     mapContactPrimary.get(conid).addError(System.Label.Tet_UniquePID);                   }
AnudeepAnudeep (Salesforce Developers) 
Map<id,Contact> mapContactPrimary = new Map<id,Contact>();
Contact cont = new Contact(Name='Test Account',LastName = 'abc');
insert cont;
mapContactPrimary.put(cont.id, cont);

Depends on the definition of your map. The code snippet is just based on the assumption

I suggest looking at this example

If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!

Anudeep