You need to sign in to do that
Don't have an account?
Valli K
how to cover bellow boolean in test class
public static boolean validatemethod (Id acc,String str,Id rec){
boolean validatemethod = true;
List<custom__c> cus = new List<custom__c>();
if(rec==null){
/
cus = [Select id,name from custom__c where account__c =:acc and Product__c =:str];
}
else{
cus = [Select id,name from custom__c where account__c =:acc and Product__c =: str and id !=:rec];
}
if(!cus.isEmpty()){
return false;
}
return validatemethod;
}
boolean validatemethod = true;
List<custom__c> cus = new List<custom__c>();
if(rec==null){
/
cus = [Select id,name from custom__c where account__c =:acc and Product__c =:str];
}
else{
cus = [Select id,name from custom__c where account__c =:acc and Product__c =: str and id !=:rec];
}
if(!cus.isEmpty()){
return false;
}
return validatemethod;
}
You need to pass the not null value to the method to record id parameters for the validatemethod methid
validatemethod(Null , null . null) -- > If
validatemethod ('recordod,'recrdva','recirdid')-- else
call the same method in 2times or create 2 test methods:
class.validatemethod(acc,str,rec);
class.validatemethod(acc,str,null); // pass here null
Hope this helps you!
If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others.
Thanks
Varaprasad
@For Salesforce Project Support: varaprasad4sfdc@gmail.com
Salesforce latest interview questions :
https://www.youtube.com/channel/UCOcam_Hb4KjeBdYJlJWV_ZA?sub_confirmation=1