Skip to content

Instantly share code, notes, and snippets.

@brianmfear
Created March 24, 2016 03:11
Show Gist options
  • Save brianmfear/7564980aac77942fb535 to your computer and use it in GitHub Desktop.
Save brianmfear/7564980aac77942fb535 to your computer and use it in GitHub Desktop.
Scheduled Execution bug
public class Scheduled implements Schedulable {
@TestVisible static Boolean executed = false;
public void execute(SchedulableContext c) {
executed = true;
}
}
@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