-
-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed
Description
Hi,
I noticed that in my tests the @after methods were not executed in the case of test timeouts. However, that only happens when the Timeout rule is used. For example, the following test is fine (in the sense After method is called as expected):
public class CheckTimeoutProblem {
@Before
public void before(){ System.out.println("Called @Before");}
@After
public void after(){System.out.println("Called @After");}
@Test(timeout = 10)
public void doFailWithTimeout(){
while(true){ int x = 0; x++;}
}
@Test
public void emptyTest(){}
}When running this, I get:
Called @before
Called @after
Called @before
Called @after
which is as expected. However, if I use Timeout Rule like:
public class CheckTimeoutProblem {
@Rule
public org.junit.rules.Timeout globalTimeout = new org.junit.rules.Timeout(200);
@Before
public void before(){ System.out.println("Called @Before");}
@After
public void after(){System.out.println("Called @After");}
@Test
public void doFailWithTimeout(){
while(true){ int x = 0; x++;}
}
@Test
public void emptyTest(){}
}Called @before
Called @after
Called @before
where the After of the timed out test is not executed :(
Metadata
Metadata
Assignees
Labels
No labels