CVS: junit/src/org/junit/tests SuiteMethodTest.java, 1.2, 1.3

David Saff <[email protected]> Mon, 09 Jul 2007 12:38:32 -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-serv18825/src/org/junit/tests

Modified Files:
	SuiteMethodTest.java 
Log Message:
Checked in new tests to clarify behavior of JUnit4TestAdaptor in the presence of @Ignore'd tests and suite() methods, in response to bug 1700187

Index: SuiteMethodTest.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/tests/SuiteMethodTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- SuiteMethodTest.java	26 Apr 2007 19:56:30 -0000	1.2
+++ SuiteMethodTest.java	9 Jul 2007 19:38:30 -0000	1.3
@@ -70,4 +70,49 @@
 		Description description= Request.aClass(CompatibilityTest.class).getRunner().getDescription();
 		assertEquals(0, description.getChildren().size());
 	}
+	
+	static public class NewTestSuiteFails {
+		@Test public void sample() {
+			wasRun= true;
+		}
+		
+		public static junit.framework.Test suite() {
+			fail("should not be called with JUnit 4 runner");
+			return null;
+		}
+	}
+	
+	@Test public void makeSureSuiteNotUsedWithJUnit4Classes() {
+		wasRun= false;
+		Result res= JUnitCore.runClasses(NewTestSuiteFails.class);
+		assertEquals(1, res.getFailureCount());
+		assertFalse(wasRun);
+	}
+	
+	static public class NewTestSuiteNotUsed {
+		private static boolean wasIgnoredRun;
+		
+		@Test public void sample() {
+			wasRun= true;
+		}
+		
+		@Ignore @Test public void ignore() {
+			wasIgnoredRun= true;
+		}
+		
+		public static junit.framework.Test suite() {
+			return new JUnit4TestAdapter(NewTestSuiteNotUsed.class);
+		}
+	}
+	
+	@Test public void makeSureSuiteNotUsedWithJUnit4Classes2() {
+		wasRun= false;
+		NewTestSuiteNotUsed.wasIgnoredRun= false;
+		Result res= JUnitCore.runClasses(NewTestSuiteNotUsed.class);
+		assertTrue(wasRun);
+		assertFalse(NewTestSuiteNotUsed.wasIgnoredRun);
+		assertEquals(0, res.getFailureCount());
+		assertEquals(1, res.getRunCount());
+		assertEquals(0, res.getIgnoreCount());
+	}
 }


-------------------------------------------------------------------------
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/