Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I make @OnApplicationStart not run on tests?

I just found out that classes annotated with @OnApplicationStart run when I run jUnit tests (via IntelliJ).

Can I disable this? I have some logic that is only relevant on real application startup, but not in tests.

like image 599
ripper234 Avatar asked Nov 30 '11 10:11

ripper234


1 Answers

Yes you can check test mode in your doJob method for that

@Override
public void doJob() throws Exception {
    if (!Play.runingInTestMode()) {
        // Do your stuff
    }
}
like image 113
Seb Cesbron Avatar answered Sep 28 '22 19:09

Seb Cesbron