Skip to content

Commit af50563

Browse files
committed
Internal cleanups regarding createTestMethodProcessorList
1 parent a30fd37 commit af50563

File tree

6 files changed

+12
-68
lines changed

6 files changed

+12
-68
lines changed

junit4/src/main/java/com/google/testing/junit/testparameterinjector/PluggableTestRunner.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ protected PluggableTestRunner(Class<?> klass) throws InitializationError {
6565
super(klass);
6666
}
6767

68-
/**
69-
* Returns the TestMethodProcessorList to use.
70-
*/
71-
@Deprecated
72-
protected TestMethodProcessorList createTestMethodProcessorList() {
73-
return TestMethodProcessorList.createNewParameterizedProcessors();
74-
}
75-
7668
/**
7769
* This method is run to perform optional additional operations on the test instance, right after
7870
* it was created.
@@ -397,7 +389,7 @@ protected final void validatePublicVoidNoArgMethods(
397389

398390
private synchronized TestMethodProcessorList getTestMethodProcessors() {
399391
if (testMethodProcessors == null) {
400-
testMethodProcessors = createTestMethodProcessorList();
392+
testMethodProcessors = TestMethodProcessorList.createNewParameterizedProcessors();
401393
}
402394
return testMethodProcessors;
403395
}

junit4/src/test/java/com/google/testing/junit/testparameterinjector/PluggableTestRunnerTest.java

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public void evaluate() throws Throwable {
8585
}
8686
}
8787

88-
@RunWith(PluggableTestRunner.class)
8988
public static class TestAndMethodRuleTestClass {
9089

9190
@Rule public TestAndMethodRule rule = new TestAndMethodRule();
@@ -99,17 +98,11 @@ public void test() {
9998
@Test
10099
public void ruleThatIsBothTestRuleAndMethodRuleIsInvokedOnceOnly() throws Exception {
101100
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
102-
new PluggableTestRunner(TestAndMethodRuleTestClass.class) {
103-
@Override
104-
protected TestMethodProcessorList createTestMethodProcessorList() {
105-
return TestMethodProcessorList.empty();
106-
}
107-
});
101+
new PluggableTestRunner(TestAndMethodRuleTestClass.class) {});
108102

109103
assertThat(ruleInvocations).hasSize(1);
110104
}
111105

112-
@RunWith(PluggableTestRunner.class)
113106
public static class RuleOrderingTestClassWithExplicitOrder {
114107

115108
@Rule(order = 3)
@@ -130,17 +123,11 @@ public void test() {
130123
@Test
131124
public void rulesAreSortedCorrectly_withExplicitOrder() throws Exception {
132125
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
133-
new PluggableTestRunner(RuleOrderingTestClassWithExplicitOrder.class) {
134-
@Override
135-
protected TestMethodProcessorList createTestMethodProcessorList() {
136-
return TestMethodProcessorList.empty();
137-
}
138-
});
126+
new PluggableTestRunner(RuleOrderingTestClassWithExplicitOrder.class) {});
139127

140128
assertThat(ruleInvocations).containsExactly("B", "C", "A").inOrder();
141129
}
142130

143-
@RunWith(PluggableTestRunner.class)
144131
public static class CustomTestAnnotationTestClass {
145132
@SuppressWarnings("JUnit4TestNotRun")
146133
@CustomTest
@@ -159,10 +146,6 @@ public void testMarkedWithCustomClassIsInvoked() throws Exception {
159146
testMethodInvocationCount = 0;
160147
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
161148
new PluggableTestRunner(CustomTestAnnotationTestClass.class) {
162-
@Override
163-
protected TestMethodProcessorList createTestMethodProcessorList() {
164-
return TestMethodProcessorList.empty();
165-
}
166149

167150
@Override
168151
protected ImmutableList<Class<? extends Annotation>> getSupportedTestAnnotations() {
@@ -173,7 +156,6 @@ protected ImmutableList<Class<? extends Annotation>> getSupportedTestAnnotations
173156
assertThat(testMethodInvocationCount).isEqualTo(2);
174157
}
175158

176-
@RunWith(PluggableTestRunner.class)
177159
public static class SortedPluggableTestRunnerTestClass {
178160
@Test
179161
public void a() {
@@ -196,10 +178,6 @@ public void testsAreSortedCorrectly() throws Exception {
196178
testOrder.clear();
197179
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
198180
new PluggableTestRunner(SortedPluggableTestRunnerTestClass.class) {
199-
@Override
200-
protected TestMethodProcessorList createTestMethodProcessorList() {
201-
return TestMethodProcessorList.empty();
202-
}
203181

204182
@Override
205183
protected ImmutableList<FrameworkMethod> sortTestMethods(

junit4/src/test/java/com/google/testing/junit/testparameterinjector/TestParameterAnnotationMethodProcessorTest.java

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,10 @@
2727
import java.util.Arrays;
2828
import java.util.Collection;
2929
import java.util.List;
30-
import java.util.function.Function;
3130
import org.junit.Test;
3231
import org.junit.runner.RunWith;
3332
import org.junit.runners.Parameterized;
3433
import org.junit.runners.Parameterized.Parameters;
35-
import org.junit.runners.model.TestClass;
3634

3735
/**
3836
* Test class to test the PluggableTestRunner test harness works with {@link
@@ -830,37 +828,28 @@ public void test() throws Exception {
830828
switch (result) {
831829
case SUCCESS_ALWAYS:
832830
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
833-
newTestRunnerWithParameterizedSupport(
834-
testClass -> TestMethodProcessorList.createNewParameterizedProcessors()));
831+
newTestRunner(/* supportLegacyFeatures= */ false));
835832
break;
836833

837834
case SUCCESS_FOR_ALL_PLACEMENTS_ONLY:
838835
assertThrows(
839836
Exception.class,
840837
() ->
841838
SharedTestUtilitiesJUnit4.runTestsAndGetFailures(
842-
newTestRunnerWithParameterizedSupport(
843-
testClass -> TestMethodProcessorList.createNewParameterizedProcessors())));
839+
newTestRunner(/* supportLegacyFeatures= */ false)));
844840
break;
845841

846842
case FAILURE:
847843
assertThrows(
848844
Exception.class,
849845
() ->
850846
SharedTestUtilitiesJUnit4.runTestsAndGetFailures(
851-
newTestRunnerWithParameterizedSupport(
852-
testClass -> TestMethodProcessorList.createNewParameterizedProcessors())));
847+
newTestRunner(/* supportLegacyFeatures= */ false)));
853848
break;
854849
}
855850
}
856851

857-
private PluggableTestRunner newTestRunnerWithParameterizedSupport(
858-
Function<TestClass, TestMethodProcessorList> processorListGenerator) throws Exception {
859-
return new PluggableTestRunner(testClass) {
860-
@Override
861-
protected TestMethodProcessorList createTestMethodProcessorList() {
862-
return processorListGenerator.apply(getTestClass());
863-
}
864-
};
852+
private PluggableTestRunner newTestRunner(boolean supportLegacyFeatures) throws Exception {
853+
return new PluggableTestRunner(testClass) {};
865854
}
866855
}

junit4/src/test/java/com/google/testing/junit/testparameterinjector/TestParameterInjectorKotlinTest.kt

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,7 @@ class TestParameterInjectorKotlinTest {
243243
@Test
244244
fun test_success() {
245245
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
246-
object : PluggableTestRunner(testClass) {
247-
override fun createTestMethodProcessorList(): TestMethodProcessorList {
248-
return TestMethodProcessorList.createNewParameterizedProcessors()
249-
}
250-
}
246+
object : PluggableTestRunner(testClass) {}
251247
)
252248
}
253249

@@ -267,7 +263,7 @@ class TestParameterInjectorKotlinTest {
267263
enum class Color {
268264
RED,
269265
BLUE,
270-
GREEN
266+
GREEN,
271267
}
272268

273269
@JvmInline value class ColorValueClass(val onlyValue: Color)

junit4/src/test/java/com/google/testing/junit/testparameterinjector/TestParameterTest.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,13 +238,7 @@ public TestParameterTest(String name, Class<?> testClass) {
238238

239239
@Test
240240
public void test() throws Exception {
241-
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(
242-
new PluggableTestRunner(testClass) {
243-
@Override
244-
protected TestMethodProcessorList createTestMethodProcessorList() {
245-
return TestMethodProcessorList.createNewParameterizedProcessors();
246-
}
247-
});
241+
SharedTestUtilitiesJUnit4.runTestsAndAssertNoFailures(new PluggableTestRunner(testClass) {});
248242
}
249243

250244
private static ImmutableList<Class<? extends Annotation>> annotationTypes(

junit4/src/test/java/com/google/testing/junit/testparameterinjector/TestParametersMethodProcessorTest.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -664,12 +664,7 @@ public void test_failure() throws Exception {
664664
}
665665

666666
private PluggableTestRunner newTestRunner() throws Exception {
667-
return new PluggableTestRunner(testClass) {
668-
@Override
669-
protected TestMethodProcessorList createTestMethodProcessorList() {
670-
return TestMethodProcessorList.createNewParameterizedProcessors();
671-
}
672-
};
667+
return new PluggableTestRunner(testClass) {};
673668
}
674669

675670
private static ImmutableList<Class<? extends Annotation>> annotationTypes(

0 commit comments

Comments
 (0)