@isTest private class RollupToUnprocessToMailBatchTest { static testMethod void testMethod1() { user UserGI = New User( Alias = 'GI_User', Email='GI_User@testorg.com', EmailEncodingKey='UTF-8', LastName='testUserGI', Firstname ='GI', LanguageLocaleKey='zh_CN', LocaleSidKey='zh_CN', ProfileId = System.Label.ProfileId_SystemAdmin, TimeZoneSidKey='Asia/Shanghai', UserName='testUserGI@testorg.com'); insert UserGI; OPDPlan__c oPDPlan0 = new OPDPlan__c(); oPDPlan0.Status__c = '提交'; oPDPlan0.OPDPlan_ImplementDate__c = Date.today().addDays(1); oPDPlan0.NoOpp_Reason__c = 'HCP对应'; oPDPlan0.SalesManager__c = UserGI.id; insert oPDPlan0; Approval.ProcessSubmitRequest psr = new Approval.ProcessSubmitRequest(); psr.setObjectId(oPDPlan0.id); psr.setSubmitterId(UserInfo.getUserId()); psr.setProcessDefinitionNameOrId('OPDApproval'); Approval.ProcessResult submitResult = Approval.process(psr); Id execBTId = Database.executeBatch(new RollupToUnprocessToMailBatch(),200); } }