Using play framework 1.2.4 with scala. I have few play jobs that looks like like
@OnApplicationStart class MyOtherJob extends Job { ... }
@Every("30s") class MyJob extends Job { ... }
These jobs are running while the application is in test mode, so they mess up things. How can I disable them from running while testing?
I tried the following application config, didn't help:
# Jobs executor
# ~~~~~~
# Size of the Jobs pool
play.jobs.pool=10
test.play.jobs.pool=0
test.cron.queue.every=never
dev.cron.queue.every=20s
prod.cron.queue.every=20s
test.cron.onApplicationStart.trigger=never
dev.cron.onApplicationStart.trigger=auto
prod.cron.onApplicationStart.trigger=auto
It is possible to check if Play is running in test mode using the following syntax.
play.Play.runingInTestMode()
Note: the spelling mistake is not accidental. That is the method name in the API.
Therefore, in your Jobs, you should be able to wrap the job execution around an IF statement using the above, and therefore, preventing test mode jobs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With