CVS: junit/src/org/junit/tests OldTestClassAdaptingListenerTest.java, NONE, 1.1 AllTestsTest.java, 1.2, 1.3 AllTests.java, 1.7, 1.8

David Saff <[email protected]>
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-serv26251/src/org/junit/tests

Modified Files:
	AllTestsTest.java AllTests.java 
Added Files:
	OldTestClassAdaptingListenerTest.java 
Log Message:
Improving test coverage on OldTestClassRunner and AllTestsRunner

--- NEW FILE: OldTestClassAdaptingListenerTest.java ---
package org.junit.tests;

import static org.junit.Assert.*;
import junit.framework.AssertionFailedError;
import junit.framework.TestCase;
import junit.framework.TestListener;
import org.junit.Test;
import org.junit.internal.runners.OldTestClassRunner;
import org.junit.runner.Result;
import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;

public class OldTestClassAdaptingListenerTest {
	@Test
	public void addFailureDelegatesToNotifier() {
		Result result= new Result();
		RunListener listener= result.createListener();
		RunNotifier notifier= new RunNotifier();
		notifier.addFirstListener(listener);
		TestListener adaptingListener= OldTestClassRunner
				.createAdaptingListener(notifier);
		TestCase testCase= new TestCase() {
		};
		adaptingListener.addFailure(testCase, new AssertionFailedError());
		assertEquals(1, result.getFailureCount());
	}
}

Index: AllTestsTest.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/tests/AllTestsTest.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- AllTestsTest.java	6 Dec 2006 01:22:48 -0000	1.2
+++ AllTestsTest.java	21 Feb 2007 15:19:39 -0000	1.3
@@ -59,4 +59,16 @@
 		AllTests tests= new AllTests(AllJUnit4.class);
 		assertEquals(1, tests.testCount());
 	}
+	
+	@RunWith(AllTests.class)
+	public static class BadSuiteMethod {
+		public static junit.framework.Test suite() {
+			throw new RuntimeException("can't construct");
+		}
+	}
+
+	@org.junit.Test(expected= RuntimeException.class)
+	public void exceptionThrownWhenSuiteIsBad() throws Throwable {
+		new AllTests(BadSuiteMethod.class);
+	}
 }

Index: AllTests.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/tests/AllTests.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- AllTests.java	26 Jan 2007 14:04:13 -0000	1.7
+++ AllTests.java	21 Feb 2007 15:19:39 -0000	1.8
@@ -6,6 +6,8 @@
 import org.junit.runners.Suite;
 import org.junit.runners.Suite.SuiteClasses;
 
+// TODO (Feb 21, 2007 10:05:41 AM):  organize these tests
+
 @RunWith(Suite.class)
 @SuiteClasses({
 	ListenerTest.class,
@@ -41,7 +43,8 @@
 	InaccessibleBaseClassTest.class,
 	SuiteMethodTest.class,
 	TestClassMethodsRunnerTest.class,
-	IgnoreClassTest.class
+	IgnoreClassTest.class,
+	OldTestClassAdaptingListenerTest.class
 })
 public class AllTests {
 	public static Test suite() {


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.