@isTest private class ConsumApplyEquipmentSetSRListCtrlTest { static ConsumTestDataFactory factory; // 造出选择完明细的申请 @testSetup static void setupTestData(){ factory = new ConsumTestDataFactory(); factory.setupTestData(); } static testMethod void testInit() { Consum_Apply__c ca = [SELECT Id FROM Consum_Apply__c LIMIT 1]; System_UserSetting__c config = System_UserSetting__c.getInstance(UserInfo.getUserId()); System.assertEquals(null, config.CAESD_Action_Type__c); PageReference ref = new PageReference('/apex/ConsumApplyEquipmentSetSRList?id=' + ca.Id); Test.setCurrentPage(ref); ConsumApplyEquipmentSetSRListController controller = new ConsumApplyEquipmentSetSRListController(); Test.startTest(); controller.init(); controller.selectedType = '发货'; controller.setType(); Test.stopTest(); config = System_UserSetting__c.getInstance(UserInfo.getUserId()); System.assertEquals('发货', config.CAESD_Action_Type__c); } }