@isTest private class OPDPlanWarningBatchTest { @Testsetup private static void init() { String timenow = Datetime.now().format('yyyyMMddHHmmss'); User hpOwner = new User(Test_staff__c = true, LastName = 'TestMao', FirstName = 'TestMaoF', Alias = 'hp', CommunityNickname = 'TestMao', Email = 'Test@sunbridge.com', Username = 'Test' + timenow + '@sunbridge.com', IsActive = true, EmailEncodingKey = 'ISO-2022-JP', TimeZoneSidKey = 'Asia/Tokyo', LocaleSidKey = 'ja_JP', LanguageLocaleKey = 'ja', ProfileId = System.Label.ProfileId_SystemAdmin, Stay_or_not__c = '已离职'); system.runAs(hpOwner) { OPDPlan__c tempOPDPlan = new OPDPlan__c(); tempOPDPlan.ThisMonthPlan__c = 1; tempOPDPlan.Status__c = '计划中'; insert tempOPDPlan; OPDPlan__c tempOPDPlan2 = new OPDPlan__c(); tempOPDPlan2.ThisMonthPlan__c = 1; tempOPDPlan2.Status__c = '计划中'; insert tempOPDPlan2; } } @isTest static void test_method_one() { Id execBTId = Database.executeBatch(new OPDPlanWarningBatch(), 40); } @isTest static void test_method_two() { Id execBTId = Database.executeBatch(new OPDPlanWarningBatch(true), 40); } }