@IsTest class LexQISCloneButtonControllerTest { public static String qisRecordTypeId = Schema.SObjectType.QIS_Report__c.getRecordTypeInfosByDeveloperName().get('QISRecordType1').getRecordTypeId(); public static User thisUser = [ SELECT Id from User WHERE Id = :UserInfo.getUserId()]; @testSetup static void testSetup() { System.runAs(thisUser){ QIS_Report__c qis = new QIS_Report__c(Name = 'Test', RecordTypeId = qisRecordTypeId, QIS_Status__c = '取消'); insert qis; } } @isTest static void tesMethod1(){ System.runAs(thisUser){ QIS_Report__c qis = [SELECT Id FROM QIS_Report__c WHERE RecordTypeId =:qisRecordTypeId LIMIT 1]; System.Test.startTest(); LexQISCloneButtonController lq = new LexQISCloneButtonController(); LexQISCloneButtonController.checkStatus(qis.Id); System.Test.stopTest(); } } }