From: David S. <ds...@us...> - 2006-10-17 19:10:25
|
Update of /cvsroot/junit/junit/org/junit/tests In directory sc8-pr-cvs6.sourceforge.net:/tmp/cvs-serv19803/org/junit/tests Modified Files: Tag: saff_r41_runner_refactoring InitializationErrorForwardCompatibilityTest.java ParameterizedTestMethodTest.java TestMethodTest.java UserStopTest.java CustomRunnerTest.java Log Message: InterpretWith allows a delegation-style, rather than inheritance-style, extension mechanism Index: InitializationErrorForwardCompatibilityTest.java =================================================================== RCS file: /cvsroot/junit/junit/org/junit/tests/InitializationErrorForwardCompatibilityTest.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- InitializationErrorForwardCompatibilityTest.java 29 Jun 2006 23:06:45 -0000 1.3 +++ InitializationErrorForwardCompatibilityTest.java 17 Oct 2006 19:10:20 -0000 1.3.2.1 @@ -10,6 +10,7 @@ import org.junit.Before; import org.junit.Test; import org.junit.internal.runners.EmptyDescription; +import org.junit.internal.runners.JavaTestInterpreter; import org.junit.internal.runners.TestClassRunner; import org.junit.runner.Description; import org.junit.runner.RunWith; @@ -94,7 +95,7 @@ public static class InitializesWithError extends TestClassRunner { public InitializesWithError(Class<?> klass) throws Exception { - super(klass); + super(klass, new JavaTestInterpreter()); throw new Exception(); } } Index: ParameterizedTestMethodTest.java =================================================================== RCS file: /cvsroot/junit/junit/org/junit/tests/ParameterizedTestMethodTest.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- ParameterizedTestMethodTest.java 15 Feb 2006 22:55:29 -0000 1.2 +++ ParameterizedTestMethodTest.java 17 Oct 2006 19:10:20 -0000 1.2.2.1 @@ -14,6 +14,7 @@ import org.junit.BeforeClass; import org.junit.Test; import org.junit.internal.runners.InitializationError; +import org.junit.internal.runners.JavaTestInterpreter; import org.junit.internal.runners.TestClassRunner; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; @@ -85,7 +86,7 @@ private List<Throwable> validateAllMethods(Class<?> clazz) { try { - new TestClassRunner(clazz); + new TestClassRunner(clazz, new JavaTestInterpreter()); } catch (InitializationError e) { return e.getCauses(); } Index: TestMethodTest.java =================================================================== RCS file: /cvsroot/junit/junit/org/junit/tests/TestMethodTest.java,v retrieving revision 1.3 retrieving revision 1.3.2.1 diff -u -d -r1.3 -r1.3.2.1 --- TestMethodTest.java 27 Apr 2006 22:11:51 -0000 1.3 +++ TestMethodTest.java 17 Oct 2006 19:10:20 -0000 1.3.2.1 @@ -15,6 +15,7 @@ import org.junit.Ignore; import org.junit.Test; import org.junit.internal.runners.InitializationError; +import org.junit.internal.runners.JavaTestInterpreter; import org.junit.internal.runners.MethodValidator; import org.junit.internal.runners.TestClassRunner; import org.junit.runner.JUnitCore; @@ -86,7 +87,7 @@ private List<Throwable> validateAllMethods(Class<?> clazz) { try { - new TestClassRunner(clazz); + new TestClassRunner(clazz, new JavaTestInterpreter()); } catch (InitializationError e) { return e.getCauses(); } Index: UserStopTest.java =================================================================== RCS file: /cvsroot/junit/junit/org/junit/tests/UserStopTest.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- UserStopTest.java 15 Feb 2006 22:55:29 -0000 1.2 +++ UserStopTest.java 17 Oct 2006 19:10:20 -0000 1.2.2.1 @@ -2,6 +2,8 @@ import org.junit.Before; import org.junit.Test; +import org.junit.internal.runners.JavaMethod; +import org.junit.internal.runners.JavaTestInterpreter; import org.junit.internal.runners.TestMethodRunner; import org.junit.runner.Description; import org.junit.runner.Request; @@ -21,8 +23,9 @@ } @Test(expected=StoppedByUserException.class) public void stopMethodRunner() throws Exception { - new TestMethodRunner(this, OneTest.class.getMethod("foo"), fNotifier, - Description.createTestDescription(OneTest.class, "foo")).run(); + // TODO: is this a good test? + new TestMethodRunner(this, new JavaMethod(OneTest.class.getMethod("foo")), fNotifier, + Description.createTestDescription(OneTest.class, "foo"), new JavaTestInterpreter()).run(); } public static class OneTest { Index: CustomRunnerTest.java =================================================================== RCS file: /cvsroot/junit/junit/org/junit/tests/CustomRunnerTest.java,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -u -d -r1.2 -r1.2.2.1 --- CustomRunnerTest.java 15 Feb 2006 22:55:29 -0000 1.2 +++ CustomRunnerTest.java 17 Oct 2006 19:10:20 -0000 1.2.2.1 @@ -1,39 +1,23 @@ package org.junit.tests; +import static org.junit.Assert.*; + import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import org.junit.Assert; import org.junit.Test; -import org.junit.internal.runners.InitializationError; -import org.junit.internal.runners.TestClassMethodsRunner; -import org.junit.internal.runners.TestClassRunner; -import org.junit.internal.runners.TestMethodRunner; +import org.junit.internal.runners.JavaMethod; +import org.junit.internal.runners.JavaTestInterpreter; import org.junit.runner.JUnitCore; -import org.junit.runner.RunWith; -import org.junit.runner.notification.RunNotifier; - -import static org.junit.Assert.*; // TODO: better factoring here public class CustomRunnerTest { - public static class CustomRunner extends TestClassRunner { - public CustomRunner(Class<?> klass) throws InitializationError { - super(klass, new TestClassMethodsRunner(klass) { - @Override - protected TestMethodRunner createMethodRunner(Object test, Method method, RunNotifier notifier) { - return new TestMethodRunner(test, method, notifier, - methodDescription(method)) { - @Override - protected void executeMethodBody() - throws IllegalAccessException, - InvocationTargetException { - super.executeMethodBody(); - assertGlobalStateIsValid(); - } - }; - } - }); + public static class CustomInterpreter extends JavaTestInterpreter { + @Override + public void executeMethodBody(Object test, JavaMethod javaMethod) + throws IllegalAccessException, InvocationTargetException { + super.executeMethodBody(test, javaMethod); + assertGlobalStateIsValid(); } } @@ -41,7 +25,7 @@ Assert.fail(); } - @RunWith(CustomRunner.class) + @InterpretWith(CustomInterpreter.class) public static class UsesGlobalState { @Test public void foo() { |