@Rule
public Timeout timeOutRule = new Timeout(2);
@Test
public void timeOutTest() throws InterruptedException {
// org.junit.runners.model.TestTimedOutException: test timed out after 2 milliseconds
Thread.sleep(3 * 1000);
}
@Test
public void infiniteLoopTest() {
// org.junit.runners.model.TestTimedOutException: test timed out after 2 milliseconds
while (true) {
}
}
@Rule
public TestName testNameRule = new TestName();
@Test
public void testMethod1() {
Assert.assertEquals("testMethod1", testNameRule.getMethodName());
}
@Test
public void testMethod2() {
Assert.assertEquals("testMethod2", testNameRule.getMethodName());
}