You need to sign in to do that
Don't have an account?
Carolyn juliana 7
Need Help with multilevel SOQL Test class
Hi ,
I have an multilevel test class but problem is i dotn see 100% coverage for the tests
Tests class is
The apex class is below
Your help is highly appreciated
Regards,
Carolyn
I have an multilevel test class but problem is i dotn see 100% coverage for the tests
Tests class is
@isTest public class testGetAllLevels { static testMethod void testGetLevel1() { Case_Type_Data__c obj = new Case_Type_Data__c(); obj.Level_1__c = 'Test Level 1'; insert obj; List<String> s = PickListHandler.getLevel1(); } static testMethod void testGetLevel2() { Case_Type_Data__c obj = new Case_Type_Data__c(); obj.Level_1__c = 'Test Level 1'; obj.Level_2__c = 'Test Level 2'; insert obj; List<String> s = PickListHandler.getLevel2('test'); } static testMethod void testGetLevel3() { Case_Type_Data__c obj = new Case_Type_Data__c(); obj.Level_1__c = 'Test Level 1'; obj.Level_2__c = 'Test Level 2'; obj.Level_3__c = 'Test Level 2'; insert obj; List<String> s = PickListHandler.getLevel3('test1','test2'); } }
The apex class is below
public class PickListHandler { @AuraEnabled public static List<String> getLevel1(){ List<String> tempLst1 = new List<String>(); for(AggregateResult ar : [select Level_1__c,COUNT(id) from Case_Type_Data__c group by Level_1__c]) { tempLst1.add(''+ar.get('Level_1__c')); } return tempLst1; } @AuraEnabled public static List<String> getLevel2(string strName){ List<String> tempLst2 = new List<String>(); for(AggregateResult ar : [select Level_2__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName group by Level_2__c]) { tempLst2.add(''+ar.get('Level_2__c')); } return tempLst2; } @AuraEnabled public static List<String> getLevel3(string strName1,string strName2){ List<String> tempLst3 = new List<String>(); for(AggregateResult ar : [select Level_3__c,COUNT(id) from Case_Type_Data__c where Level_1__c=:strName1 and Level_2__c=:strName2 group by Level_3__c]) { tempLst3.add(''+ar.get('Level_3__c')); } return tempLst3; } }here is coverage
Your help is highly appreciated
Regards,
Carolyn
Best Answer chosen by Carolyn juliana 7
David Zhu 🔥
You may need to change these two test methods.