//需要实现
Schedulable接口,实现
execute方法
public class MerchandiseSchedule implements Schedulable{ public void execute(SchedulableContext sc){ MerchandiseBatch batchUtil = new MerchandiseBatch(); Database.executeBatch(batchUtil); } }
@isTest private class TestGoodsSchedule { static testMethod void myUnitTest(){ String executeTime = '0 10 2 * * ?'; MerchandiseSchedule scheduleMer = new MerchandiseSchedule(); System.schedule('batch goods',executeTime,scheduleMer); } }
test的结果如下图所示