How to define JUnit test time-out at runtime (i.e. without annotations)?
问题 I want to run a unit test with a time-out that is defined at runtime. I want to define a time-out for a specific test only, not the whole class. I saw these are the ways to set the time out: @Rule public Timeout globalTimeout = new Timeout(10000); // 10 seconds max per method tested or @Test(timeout=100) public void infinity() { while(true); } but when I run this code, no exception is thrown. I want to identify when the test failed due to timeout. public Timeout testTimeout; private void