Is there a way in JUnit to define a global timeout/limit for all the tests included in the suite.
Well, let me to explain this a little.
I want to introduce a junit test suite into the build system of a legacy project that would be run on every build. The suite should consist of fast running unit tests, but the project has mixed set of integration and unit tests in it's tests source folder.
So what I am aiming for is introducing a central test suite for unit tests that only contains those tests that are capable of running within a certain time limit (each test individually).
I want to enforce that rule by introducing a @Rule
annotation if possible.
I did try this:
@RunWith(Suite.class)
@SuiteClasses({...})
public class FastTestSuite{
@Rule Timeout timeout = new Timeout(1);
}
but this did not seem to do the trick. I know for a fact that there are tests that tun much slower than 1 millisecond, but none of the tests failed.