Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JUnit 5 -- global timeout?

Tags:

junit

junit5

In JUnit 5, what is the best way to enforce a global timeout for all tests?

I see that JUnit 4 has a @Rule feature, but this has been removed in JUnit 5. And I would prefer not to have to copy-paste assertTimeoutPreemptively for every test.

like image 710
Travis Avatar asked Oct 31 '17 17:10

Travis


1 Answers

Junit 5.5 does support "global timeout". Just have a look at documentation of corresponding property knobs.

For example, try to open file src/test/resources/junit-platform.properties and paste there:

junit.jupiter.execution.timeout.default=42 ms
like image 192
Lubo Avatar answered Oct 18 '22 17:10

Lubo