+ Start a Discussion
OssieOssie 

Test Class for Query Locator

Hi All,

 

I currently have 67% code coverage for one of my apex classes but, I'm struggling to cover the following lines:

 

 

if (caseOwner=='' && contactName=='' && accountname!='')
{ 

con = new ApexPages.StandardSetController(Database.getQueryLocator([SELECT Owner.Name, Account.Name, Contact.Name FROM Case WHERE RecordTypeId =:RecordTypeId AND Account.Name LIKE :accountname]));
con.setPageSize(200);

}

 Any help on how i can cover these lines would be greatly appreciated!! 

Alok_NagarroAlok_Nagarro

Hi,

 

Could you pls post your complete testMethod for better understanding ?

OssieOssie

Here you go.....thanks!!

 

@isTest    
    
    private class TestCaseController3 {  
    
       Static testMethod void testTHdSearchPage() {    
       PageReference pageRef = Page.SearchQuery3;
       Test.setCurrentPage(pageRef);
             
       CaseController3 controller = new CaseController3();            
       
       Controller = new CaseController3();
       Controller.setthdTeam('UK');      
       Controller.setgroupBrand('MFF');
       Controller.setcaseOrigin('Email');
       Controller.setstatus('New');
       Controller.setaffectedArea('Electrics');
       Controller.setcustomerQuestion('Part Number');
       Controller.setinformationSource('Bulletins');
       Controller.setcallSource('Dealer');
       Controller.setproductGroup('Tractor');
      
       List<SelectOption> TestproductGroup = controller.getproductGroup();     
      
       List<SelectOption> TestgroupBrand = controller.getgroupBrand();
       List<SelectOption> TestthdTeam = controller.getthdTeam();
       List<SelectOption> TestcaseOrigin = controller.getcaseOrigin();
       List<SelectOption> TestcustomerQuestion = controller.getcustomerQuestion();
       List<SelectOption> TestinformationSource = controller.getinformationSource();
       List<SelectOption> TestcallSource = controller.getcallSource();
       List<SelectOption> Teststatus = controller.getstatus();
       List<SelectOption> TestaffectedArea = controller.getaffectedArea();
       
       Controller.setproductGroup('Balers (Round / Square)');
       List<SelectOption> TestproductGroup011 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand022 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea033 = controller.getaffectedArea();
       
       Controller.setproductGroup('Agtv');
       List<SelectOption> TestproductGroup11 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand22 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea33 = controller.getaffectedArea();
      
       Controller.setproductGroup('Combine');
       List<SelectOption> TestproductGroup111 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand222 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea333 = controller.getaffectedArea();
          
       Controller.setproductGroup('Cultivators');
       List<SelectOption> TestproductGroup1121 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand2222= controller.getgroupBrand();
       List<SelectOption> TestaffectedArea3233 = controller.getaffectedArea();
      
       Controller.setproductGroup('Disc Harrows');
       List<SelectOption> TestproductGroup7 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand7 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea7 = controller.getaffectedArea();
       
       Controller.setproductGroup('Drills / Planters');
       List<SelectOption> TestproductGroup77 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand77 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea77 = controller.getaffectedArea();

       Controller.setproductGroup('Loaders');
       List<SelectOption> TestproductGroup78 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand78 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea78 = controller.getaffectedArea();

       Controller.setproductGroup('Material Handlers');
       List<SelectOption> TestproductGroup79 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand79 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea79 = controller.getaffectedArea();

       Controller.setproductGroup('Mowers');
       List<SelectOption> TestproductGroup8 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand8 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea8 = controller.getaffectedArea();

       Controller.setproductGroup('Ploughs');
       List<SelectOption> TestproductGroup80 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand80 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea80 = controller.getaffectedArea();

       Controller.setproductGroup('SP Forager');
       List<SelectOption> TestproductGroup81 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand81 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea81 = controller.getaffectedArea();

       Controller.setproductGroup('SP Sprayers');
       List<SelectOption> TestproductGroup82 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand82 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea82 = controller.getaffectedArea();
       
       Controller.setproductGroup('Trailers / Spreaders');
       List<SelectOption> TestproductGroup83 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand83 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea83 = controller.getaffectedArea();

       Controller.setproductGroup('SP Windrowers');
       List<SelectOption> TestproductGroup84 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand84 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea84 = controller.getaffectedArea();

       Controller.setproductGroup('Generators');
       List<SelectOption> TestproductGroup85 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand85 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea85 = controller.getaffectedArea();

       Controller.setproductGroup('Groundscare / Mowers');
       List<SelectOption> TestproductGroup86 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand86 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea86 = controller.getaffectedArea();
        
       Controller.setproductGroup('-None-');
       List<SelectOption> TestproductGroup87 = controller.getproductGroup();       
       List<SelectOption> TestgroupBrand87 = controller.getgroupBrand();
       List<SelectOption> TestaffectedArea87 = controller.getaffectedArea();
 
       CaseController3 controller1 = new CaseController3();

       Controller1.setthdTeam('UK');      
       Controller1.setgroupBrand('MFF');      
       Controller1.setcaseOrigin('Email');
       Controller1.setstatus('New');
       Controller1.setaffectedArea('Electrics');
       Controller1.setcustomerQuestion('Part Number');
       Controller1.setinformationSource('Bulletins');
       Controller1.setcallSource('Dealer');
 
       }
    
}