开发者

How to make an application with scheduler (Quartz) manually testable?

We're building a financial application with quite a lot of scheduled processing. We want to make manual testing of the application easy, but because most of the processes take months to finish, we need to give testers an option to move the current date forward.

It's not a problem to fake current date for all of our business services, because all of them access date indirectly through a "TimeService". The problem we run into is with the scheduler (Quartz).开发者_如何学Go It's not possible to move scheduler's current date into the future (nor past, but that just doesn't make much sense). I understand it's probably not the best idea to mess with Scheduler's current time when it's running, but if you could start the scheduler with an offset time interval relative to current date, there should be no logical problem with that - Quartz should just find all missed executions and handle them according to configured misfire instructions.

So to be a little more specific in this general design question:

  1. Is it possible to fake current date for Quartz?
  2. If not, what's the way you design this "magic time button for testers" that takes the application to the future? Especially regarding scheduled tasks...

Just to be clear - we're not having problems with our automatic tests (no need for scheduler there) and we're not trying to test the scheduler itself.


I'll just highlight the solution we ended up implementing for other people that might be interested. In the end, we did not use Quartz in the development environment at all. Scheduler is only running in the production configuration (where it's obviously not possible to shift time). Then we have a special piece of code that launches daily processing for every day when shifting time (which is only present in development / test environment).

The bottom line for us: don't try to combine scheduler & moving time into the future - create separate configuration with one XOR another with special logic to replace scheduler in the scheduler-less configuration.


Your only real option is to advance the system's time before starting the scheduler.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜