CVS: junit/src/org/junit/internal/runners OldTestClassRunner.java, 1.2, 1.3
David Saff <[email protected]>
| Newsgroups | gmane.comp.java.junit.devel |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/junit/junit/src/org/junit/internal/runners
In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv26251/src/org/junit/internal/runners
Modified Files:
OldTestClassRunner.java
Log Message:
Improving test coverage on OldTestClassRunner and AllTestsRunner
Index: OldTestClassRunner.java
===================================================================
RCS file: /cvsroot/junit/junit/src/org/junit/internal/runners/OldTestClassRunner.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- OldTestClassRunner.java 8 Feb 2007 22:45:21 -0000 1.2
+++ OldTestClassRunner.java 21 Feb 2007 15:19:39 -0000 1.3
@@ -15,7 +15,49 @@
import org.junit.runner.notification.RunNotifier;
public class OldTestClassRunner extends Runner {
-
+ private static final class OldTestClassAdaptingListener implements
+ TestListener {
+ private final RunNotifier fNotifier;
+
+ private OldTestClassAdaptingListener(RunNotifier notifier) {
+ fNotifier= notifier;
+ }
+
+ public void endTest(Test test) {
+ // TODO: uncovered
+ fNotifier.fireTestFinished(asDescription(test));
+ }
+
+ public void startTest(Test test) {
+ fNotifier.fireTestStarted(asDescription(test));
+ }
+
+ // Implement junit.framework.TestListener
+ public void addError(Test test, Throwable t) {
+ Failure failure= new Failure(asDescription(test), t);
+ fNotifier.fireTestFailure(failure);
+ }
+
+ private Description asDescription(Test test) {
+ if (test instanceof JUnit4TestCaseFacade) {
+ JUnit4TestCaseFacade facade= (JUnit4TestCaseFacade) test;
+ return facade.getDescription();
+ }
+ return Description.createTestDescription(test.getClass(), getName(test));
+ }
+
+ private String getName(Test test) {
+ if (test instanceof TestCase)
+ return ((TestCase) test).getName();
+ else
+ return test.toString();
+ }
+
+ public void addFailure(Test test, AssertionFailedError t) {
+ addError(test, t);
+ }
+ }
+
private Test fTest;
@SuppressWarnings("unchecked")
@@ -31,48 +73,12 @@
@Override
public void run(RunNotifier notifier) {
TestResult result= new TestResult();
- result.addListener(getListener(notifier));
+ result.addListener(createAdaptingListener(notifier));
fTest.run(result);
}
- private TestListener getListener(final RunNotifier notifier) {
- return new TestListener() {
- public void endTest(Test test) {
- // TODO: uncovered
- notifier.fireTestFinished(asDescription(test));
- }
-
- public void startTest(Test test) {
- notifier.fireTestStarted(asDescription(test));
- }
-
- // Implement junit.framework.TestListener
- //TODO method not covered
- public void addError(Test test, Throwable t) {
- Failure failure= new Failure(asDescription(test), t);
- notifier.fireTestFailure(failure);
- }
-
- private Description asDescription(Test test) {
- if (test instanceof JUnit4TestCaseFacade) {
- JUnit4TestCaseFacade facade= (JUnit4TestCaseFacade) test;
- return facade.getDescription();
- }
- return Description.createTestDescription(test.getClass(), getName(test));
- }
-
- private String getName(Test test) {
- if (test instanceof TestCase)
- return ((TestCase) test).getName();
- else
- return test.toString();
- }
-
- //TODO method not covered
- public void addFailure(Test test, AssertionFailedError t) {
- addError(test, t);
- }
- };
+ public static TestListener createAdaptingListener(final RunNotifier notifier) {
+ return new OldTestClassAdaptingListener(notifier);
}
@Override
-------------------------------------------------------------------------
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