My application has several jobs which runs 4-6 times a day and changes the system state and many configurations. Now I want to write automation test cases which will verify this state transitions and configuration changes accordingly.

I have think two approaches-

  1. write some test cases and on particular verification steps I can add some precondition that this test steps should wait until 11am for example.
  2. Second is that I will use jenkins etc. and schedule my test cases for a particular time. In this approach I guess I will have to divide the test case to the smaller test case so that I can schedule one part to run in morning and other in noon.

I am just willing to follow the best approach, these two came in my mind. Please suggest if there are some better approaches available.

2 Answers 2


I don't know about "the best approach" but I'd prefer a more continuous feedback way. If you introduce some form of timetravel in your tests / code that forces the environment to believe the time is something else, then you can test these triggers at any time continuously.

This way however requires you to have access to the code or developer buy in to achieve.

public void shouldHateMondays() throws Exception
    final TimeStub testTime = new TimeStub();
    MyTimeAwareApplication myTimeAwareApplication = new MyTimeAwareApplication(testTime);
    final Garfield garfield = myTimeAwareApplication.createGarfield();


    testTime.timeTravelTo("monday"); // constantly updates the time until it reaches destination to trigger all events


In this example I would wire in my special Time stub that i can control, while in production I would pass in a RealTime object. which would just query System.currentTimeMillis()

  • Thanks @Kiwio for the solutions, but in my case I dont have access to any development environment or developers. So I require an approach where I can perform the things independently without changing anything in the application. May 10, 2016 at 9:09
  • 1
    That's a shame, I would go with your original option to set up the test to be time triggered in Jenkins then. If possibly I would query if it would be possible to have more access to the developers as it would really help your testing process May 10, 2016 at 10:13

Since you have mentioned that your application runs 4-6 times a day and each time it changes the state of the system. Well I suppose you can use this change of state to trigger your test scripts.

  1. You can ask the developers to add a trigger in the application which will invoke the test script each time the state of the system changes. This way you won't have to define fix time intervals to run your tests.
  2. You can have a cron job setup for your test scripts which at regular intervals will check the state of the system. If any change of state is found then the tests will be invoked and executed.

If neither of these are convenient for you then you can go ahead with scheduling the tests to run at specified time intervals.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.