@isTest private class updateCampaignMailflg7BeTrueBatchTest { static testMethod void testMethod1() { RecordType rectCam = [select Id from RecordType where IsActive = true and SobjectType = 'Campaign' and DeveloperName = 'BusinessTraining']; Campaign cam = new Campaign(); cam.Name = 'cam'; cam.Name2__c = '1234'; cam.RecordTypeId = rectCam.Id; cam.Meeting_Type__c = '赞助会'; cam.HostName__c = 'test12'; cam.cooperatorCompany__c = 'test34'; cam.StartDate = Date.today().addDays(7); cam.StartDate__c = Date.today().addDays(7); cam.EndDate = Date.today().addDays(18); cam.Status = '草案中'; cam.Open_day__c = Date.today(); insert cam; Campaign cam1 = [select id,BetweenTodayStartDate__c from Campaign where id = :cam.Id]; System.debug('20000000000000000000000000'+cam1 +' ::'+cam1.BetweenTodayStartDate__c); BatchIF_Log__c log = new BatchIF_Log__c(); log.Type__c = 'updateCampaignMailflg7BeTrue'; log.ErrorLog__c = '更新:'+cam.Id+'失败\n'; insert log; System.Test.startTest(); String CRON_EXP = '0 0 0 3 9 ? 2022'; system.schedule('updateCampaignMailflg7BeTrueSchedulable', CRON_EXP, new updateCampaignMailflg7BeTrueSchedulable()); Database.executeBatch(new updateCampaignMailflg7BeTrueBatch()); Database.executeBatch(new updateCampaignMailflg7BeTrueBatch(log.Id)); System.Test.stopTest(); } }