You're going to have to fake it. What I do in situations like this is create a property with a getter and setter, but where the setter can only be used in tests. As an example, setup a new property: public static Integer runningJobCount{ get{ if(runningJobCount == null) return [Select count() FROM AsyncApexJob WHERE JobType='BatchApex' AND(Status = 'Processing' OR Status = 'Preparing')]; else return runningJobCount; } set{ System.assert(Test.isRunningTest(),'This property may only be set in tests'); runningJobCount = val; } } Then change this line: if([Select count() FROM AsyncApexJob WHERE JobType='BatchApex' AND(Status = 'Processing' OR Status = 'Preparing')]<5){ to if(runningJobCount <5){ Then in your test you can set *Schedule_Batch.runningJobCount = 5;* in the test you want to test this scenario.