You need to sign in to do that
Don't have an account?
Devadarsi Devasis 9
Can anyone provide me a simple test class for my apex class?
public with sharing class dsiplaycases {
@AuraEnabled
public static Integer TotalRecords(){
return [Select count() from Case];
}
@AuraEnabled(cacheable=true)
public static List<Case> getCaseList(){
return [select id, casenumber, subject,acc__c,reason,status,origin,con__c from case WITH SECURITY_ENFORCED ];
}
@AuraEnabled(cacheable=true)
public static List<Case> getCaseList(Integer v_Offset, Integer v_pagesize){
return [select id, casenumber, subject,acc__c,reason,status,origin,con__c from case limit :v_pagesize OFFSET :v_Offset];
}
@AuraEnabled(cacheable=true)
public static Integer getNext(Integer v_Offset, Integer v_pagesize){
v_Offset += v_pagesize;
return v_Offset;
}
@AuraEnabled(cacheable=true)
public static Integer getPrevious(Integer v_Offset, Integer v_pagesize){
v_Offset -= v_pagesize;
return v_Offset;
}
}
@AuraEnabled
public static Integer TotalRecords(){
return [Select count() from Case];
}
@AuraEnabled(cacheable=true)
public static List<Case> getCaseList(){
return [select id, casenumber, subject,acc__c,reason,status,origin,con__c from case WITH SECURITY_ENFORCED ];
}
@AuraEnabled(cacheable=true)
public static List<Case> getCaseList(Integer v_Offset, Integer v_pagesize){
return [select id, casenumber, subject,acc__c,reason,status,origin,con__c from case limit :v_pagesize OFFSET :v_Offset];
}
@AuraEnabled(cacheable=true)
public static Integer getNext(Integer v_Offset, Integer v_pagesize){
v_Offset += v_pagesize;
return v_Offset;
}
@AuraEnabled(cacheable=true)
public static Integer getPrevious(Integer v_Offset, Integer v_pagesize){
v_Offset -= v_pagesize;
return v_Offset;
}
}
Test class for AuraEnabled methods is done in the same way you would test any other code, by executing the method under test. For example:
If you find this information helpful, please mark this answer as Best. It may help others in the community. Thank You!
Anudeep
The code you provided is showing error:
At line 7 its showing: Method does not exist or incorrect signature: void TotalRecords(String, String) from the type dsiplaycases
At line 25 and 32 its showing: Illegal assignment from Integer to List<Case>
Can you please help me out.
Please replace TestTotalRecords() method with the following
Let me know if it gives you any coverage