junit-team/junit — pull request #772 by reinholdfuereder (2013-11-23 20:13:59+00:00)
Title: Optional global timeout via system property

Ideas behind this initial commit for discussion/review on global timeouts are:
(1) I want to make sure that the set of unit tests really only consists of unit tests, i.e. they need to be very fast (to be executable in each incremental build), so I would like to set a global timeout (certainly not on each single test class or test case) of e.g. 50ms (in fact it should be of course even smaller, but one should scare all devs off right away...).
(2) To avoid very long builds or even infinitely stuck builds due to very slow or even infinitely stuck tests by just setting a tolerant maximum timeout: again I only want to do that once (globally) for all the tests in a build.

Note that different global timeout strategy variants can be useful:
(a) should the global timeout conditionally override specific test timeouts that are higher then the global timeout? to make sure a maximum test duration is not exceeded; also allows to test that something really must be very quick
(b) should a specific timeout always override the global timeout? e.g. to avoid the need to increase the global timeout, just because a single test takes longer

There is a test for variant (a).

What do you think?