I want to run jUnit test cases in a java program and to stop the run after a timeout. To execute the tests I use the run(Request) method of JUnitCore.
The test classes contain methods which take a lot of time and/or do not terminate. Thus, I want to be able to stop the execution.
However, jUnit's pleaseStop flag is only taken in account after a completed test case, the methods can't be interrupted and the content (e. g. used IO resources which could be closed) is not known. Furthermore, I would like to avoid using a process.
Is there any other way to stop the execution of a single test case?
Would it be ok to use Thread.suspend() under the condition that I don't share any resources among threads?
(I've read Why are Thread.stop, Thread.suspend and Thread.resume Deprecated?)