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.
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
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