From: David S. <ds...@us...> - 2007-07-02 21:00:00
|
Update of /cvsroot/junit/junit/src/org/junit/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv512/src/org/junit/tests Modified Files: TimeoutTest.java Log Message: Fixed bug 1745048: @After method not called after my test timeout in 4.3.1 Index: TimeoutTest.java =================================================================== RCS file: /cvsroot/junit/junit/src/org/junit/tests/TimeoutTest.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- TimeoutTest.java 13 Dec 2006 02:10:51 -0000 1.5 +++ TimeoutTest.java 2 Jul 2007 20:59:57 -0000 1.6 @@ -1,6 +1,8 @@ package org.junit.tests; +import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; @@ -10,6 +12,7 @@ import junit.framework.JUnit4TestAdapter; import junit.framework.TestResult; +import org.junit.After; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.JUnitCore; @@ -138,4 +141,21 @@ new JUnit4TestAdapter(InfiniteLoopTest.class).run(result); assertEquals(1, result.errorCount()); } + + public static class WillTimeOut { + static boolean afterWasCalled= false; + + @Test(timeout=1) public void test() { + for(;;); + } + + @After public void after() { + afterWasCalled= true; + } + } + + @Test public void makeSureAfterIsCalledAfterATimeout() { + JUnitCore.runClasses(WillTimeOut.class); + assertThat(WillTimeOut.afterWasCalled, is(true)); + } } |