Created
March 24, 2016 03:11
-
-
Save brianmfear/7564980aac77942fb535 to your computer and use it in GitHub Desktop.
Scheduled Execution bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Scheduled implements Schedulable { | |
@TestVisible static Boolean executed = false; | |
public void execute(SchedulableContext c) { | |
executed = true; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@isTest class ScheduledTest { | |
@isTest static void test() { | |
Scheduled s = new Scheduled(); | |
Id jobId = System.schedule('Job', '0 0 0 * * ?', s); | |
Test.startTest(); | |
Test.stopTest(); | |
CronTrigger t = [SELECT TimesTriggered FROM CronTrigger]; | |
System.assert(Scheduled.executed); | |
System.assertEquals(jobId, t.Id); | |
// Assertion fails here | |
System.assertEquals(1, t.TimesTriggered); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment