+ Start a Discussion
Cris9931Cris9931 

I can't figure it out how to cover these 6 lines of code in Test Class

Hi, how can I cover these remaining lines for this class? I'm struggling to understand why it is not covering all.. This is my class and coverage, I have 66% until now.

User-added image
This is my method from the test class which covers 66%.

 

static testMethod void linkTest() {

        
       	SVMXC__Service_Request__c sr = new SVMXC__Service_Request__c();
        sr.SVMXC__Status__c = 'Closed';
        sr.SVMXC__Priority__c = 'Medium';
        sr.Number_of_Open_Admin_Tasks__c = 2;
        sr.SVMXC__Type__c = 'Complaint CCM';
        insert sr;
        
    	List<SVMXC__Service_Request__c> listSr = [Select Id, SVMXC__Status__c, Name from SVMXC__Service_Request__c where Id=: sr.Id ];
    	
    	ApexPages.StandardSetController setCtr = new ApexPages.StandardSetController(listSr);
    	setCtr.setSelected(new SVMXC__Service_Request__c[]{sr});
        MassUpdateSimpleControllerServiceRequest controller = new MassUpdateSimpleControllerServiceRequest(setCtr);
		
		// verify following exceptions will not cause exception
		System.assert(controller.step1()!=null);   
        controller.lexstep1();
		System.assert(controller.step2()!=null);
        controller.lexstep2();
        controller.getFieldTypeOptions();
		System.assert(controller.step3()!=null);
        controller.lexstep3();
		System.assert(controller.step4()!=null);
        controller.lexstep4();
		System.assert(controller.step5()!=null);
        controller.lexstep5();
		//System.assert(controller.cancel()!=null);
		
	
    }
Best Answer chosen by Cris9931
leonardokipperleonardokipper
static testMethod void massUpdate() {
        Account acc = new Account();
        acc.Name = 'ABC Labs';
        insert acc;
        List<Account> accLst = new List<Account>{acc};
        Test.startTest();
            String value = 'This is my test desciption';
            new MassUpdater(accLst, Account.Description, value).massUpdate();
            //ToDo assert ApexPages.Message success message
            //System.assertEquals('Updated '+accLst.size()+ ' Records', new MassUpdater(accLst, Account.Description, value).massUpdate().getSummary());
            System.assertEquals(value, [SELECT Description FROM Account WHERE Id = :acc.Id].Description);
            new MassUpdater(accLst, Account.Name, '').massUpdate();
            //ToDo assert ApexPages.Message
            //System.assertEquals('Updated '+accLst.size()+ ' Records', new MassUpdater(accLst, Account.Description, '').massUpdate().getSummary());
            System.assertNotEquals('', [SELECT Name FROM Account WHERE Id = :acc.Id].Name);
        Test.stopTest();
    }