JUnit 5 — global timeout?
问题 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. 回答1: You mentioned the JUnit 4 Timeout @Rule, which allows specifying timeouts on a per-test class basis. JUnit 5.5 has a direct equivalent as an experimental feature in the @Timeout annotation. This can be applied to the class level in the same manner as