You need to sign in to do that
Don't have an account?
Abhilash Daslal
test method for the following method
Hi Guys,
Please give the test class for the following class
Public class getAccounts{
private String getAccountRecords(String AccuntId, String accountFor){
String recordId;
List<Account> accList =[Select id,Name,phone,Email from Account LIMIT 1];
if(!accList.isEmpty()){
recordId = accList[0].id;
}
return recordId;
}
}
Please give the test class for the following class
Public class getAccounts{
private String getAccountRecords(String AccuntId, String accountFor){
String recordId;
List<Account> accList =[Select id,Name,phone,Email from Account LIMIT 1];
if(!accList.isEmpty()){
recordId = accList[0].id;
}
return recordId;
}
}
You will have to add @testVisible annotation in your controller as the method is private. PFB the test class which will give you 100% code coverage.
Apex class:
Test class:
Note: I have took value of parameter accountFor as XYZ for test purpose. You can modify as per your requirement. Also there is no standard field - Email present on Account object, if it is custom field then please append __c and in test class set some value i.e.acct.email__c='abc@ss.com'
Kindly mark this as a best answer if it helps you.
Regards,
Sagar
All Answers
You will have to add @testVisible annotation in your controller as the method is private. PFB the test class which will give you 100% code coverage.
Apex class:
Test class:
Note: I have took value of parameter accountFor as XYZ for test purpose. You can modify as per your requirement. Also there is no standard field - Email present on Account object, if it is custom field then please append __c and in test class set some value i.e.acct.email__c='abc@ss.com'
Kindly mark this as a best answer if it helps you.
Regards,
Sagar
String AccuntId, String accountFor parameters you are not using inside the method! so, no use of them.
Thanks,
Abhilash