You need to sign in to do that
Don't have an account?
dinesh abc
how to write test class for Aura enabled
public inherited sharing class LWCExampleController {
@AuraEnabled(Cacheable = true)
public static list<Account> fetchAccounts(String strObjectName) {
if(String.isNotBlank(strObjectName)) {
return Database.query('SELECT Id, Name, Industry From ' + strObjectName + ' limit 10');
}
else {
return null;
}
}
}
@AuraEnabled(Cacheable = true)
public static list<Account> fetchAccounts(String strObjectName) {
if(String.isNotBlank(strObjectName)) {
return Database.query('SELECT Id, Name, Industry From ' + strObjectName + ' limit 10');
}
else {
return null;
}
}
}
Try above test class.
Mark this as the best answer it will resolve your issue.
Thanks!
Chirag
Test class for aura controllers is same as test classes for any other apex class.
Try this code
Please refer below link which might help you in this
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_qs_test.htm
Hope this helps you
Let me know if this helps you. Kindly mark it as solved so that it may help others in future.
Thanks and Regards
Try with this code.
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.
Thanks and Regards,
Sachin Arora