CVS: junit/src/org/junit/tests TimeoutTest.java, 1.5, 1.6
David Saff <[email protected]> Mon, 02 Jul 2007 13:59:59 -0700
| Newsgroups | gmane.comp.java.junit.devel |
|---|---|
| Message-ID | <[email protected]> |
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));
+ }
}
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/