Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Added AfterParameterize and BeforeParameterize to allow metho…

…ds to run before and after parameterized tests"

This reverts commit 6abd4e6.

This should be considered in a branch, not ready for master
on this yet.
  • Loading branch information...
commit b5e9885854a0d594451800b9127eb50afb645433 1 parent b5e956d
David Saff authored
View
47 src/main/java/org/junit/runners/Parameterized.java
@@ -9,8 +9,6 @@
import java.util.Collections;
import java.util.List;
-import org.junit.internal.runners.statements.RunAfters;
-import org.junit.internal.runners.statements.RunBefores;
import org.junit.runner.Runner;
import org.junit.runner.notification.RunNotifier;
import org.junit.runners.model.FrameworkMethod;
@@ -74,24 +72,6 @@
public static @interface Parameters {
}
- /**
- * Annotation for a method which executes before a instance of <code>Parameterized</code> tests
- * are ran.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- public static @interface AfterParameterize {
- }
-
- /**
- * Annotation for a method which executes before a instance of <code>Parameterized</code> tests
- * are ran.
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.METHOD)
- public static @interface BeforeParameterize {
- }
-
private class TestClassRunnerForParameters extends
BlockJUnit4ClassRunner {
private final int fParameterSetNumber;
@@ -140,32 +120,7 @@ protected void validateZeroArgConstructor(List<Throwable> errors) {
@Override
protected Statement classBlock(RunNotifier notifier) {
- Statement statement= childrenInvoker(notifier);
- statement= withBeforeParameterize(statement);
- statement= withAfterParameterize(statement);
- return statement;
- }
-
- /**
- * Returns a {@link Statement}: run all non-overridden {@code @AfterParameterize} methods on this class
- * and superclasses before executing {@code statement}; if any throws an
- * Exception, stop execution and pass the exception on.
- */
- protected Statement withAfterParameterize(Statement statement) {
- List<FrameworkMethod> afterParameterizes = getTestClass().getAnnotatedMethods(AfterParameterize.class);
- statement= new RunAfters(statement, afterParameterizes, null);
- return statement;
- }
-
- /**
- * Returns a {@link Statement}: run all non-overridden {@code @BeforeParameterize} methods on this class
- * and superclasses before executing {@code statement}; if any throws an
- * Exception, stop execution and pass the exception on.
- */
- protected Statement withBeforeParameterize(Statement statement) {
- List<FrameworkMethod> beforeParameterizes = getTestClass().getAnnotatedMethods(BeforeParameterize.class);
- statement= new RunBefores(statement, beforeParameterizes, null);
- return statement;
+ return childrenInvoker(notifier);
}
}
View
90 src/test/java/org/junit/tests/running/classes/ParameterizedTestTest.java
@@ -19,8 +19,6 @@
import org.junit.runner.RunWith;
import org.junit.runner.Runner;
import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.AfterParameterize;
-import org.junit.runners.Parameterized.BeforeParameterize;
import org.junit.runners.Parameterized.Parameters;
import org.junit.runners.model.InitializationError;
@@ -113,94 +111,6 @@ public void beforeAndAfterClassAreRun() {
fLog= "";
JUnitCore.runClasses(BeforeAndAfter.class);
assertEquals("before after ", fLog);
- }
-
- @RunWith(Parameterized.class)
- static public class BeforeAndAfterParameterize {
- @BeforeParameterize
- public static void beforeParameterize() {
- fLog+= "beforeParameterize ";
- }
-
- @AfterParameterize
- public static void afterParameterize() {
- fLog+= "afterParameterize ";
- }
-
- public BeforeAndAfterParameterize(int x) {
-
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] { { 3 }, { 4 } });
- }
-
- @Test
- public void aTest() {
- fLog+= "aTest ";
- }
-
- @Test
- public void bTest() {
- fLog+= "bTest ";
- }
- }
-
- @Test
- public void beforeAndAfterParameterizeAreRun() {
- fLog= "";
- JUnitCore.runClasses(BeforeAndAfterParameterize.class);
- assertEquals("beforeParameterize aTest bTest afterParameterize beforeParameterize aTest bTest afterParameterize ", fLog);
- }
-
- @RunWith(Parameterized.class)
- static public class BeforeAfterParameterizeAndBeforeAfterClass {
- @BeforeParameterize
- public static void beforeParameterize() {
- fLog+= "beforeParameterize ";
- }
-
- @AfterParameterize
- public static void afterParameterize() {
- fLog+= "afterParameterize ";
- }
-
- @BeforeClass
- public static void beforeClass() {
- fLog+= "beforeClass ";
- }
-
- @AfterClass
- public static void afterClass() {
- fLog+= "afterClass ";
- }
-
- public BeforeAfterParameterizeAndBeforeAfterClass(int x) {
-
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- return Arrays.asList(new Object[][] { { 3 }, { 4 } });
- }
-
- @Test
- public void aTest() {
- fLog+= "aTest ";
- }
-
- @Test
- public void bTest() {
- fLog+= "bTest ";
- }
- }
-
- @Test
- public void beforeAfterParameterizeAndBeforeAfterClassAreRun() {
- fLog= "";
- JUnitCore.runClasses(BeforeAfterParameterizeAndBeforeAfterClass.class);
- assertEquals("beforeClass beforeParameterize aTest bTest afterParameterize beforeParameterize aTest bTest afterParameterize afterClass ", fLog);
}
@RunWith(Parameterized.class)
Please sign in to comment.
Something went wrong with that request. Please try again.