Skip to content

Commit 2c30e6d

Browse files
committed
move validation
1 parent 70de721 commit 2c30e6d

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

src/main/java/org/junit/runners/Parameterized.java

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.junit.runners;
22

3+
import java.lang.annotation.Annotation;
34
import java.lang.annotation.ElementType;
45
import java.lang.annotation.Inherited;
56
import java.lang.annotation.Retention;
@@ -267,6 +268,21 @@ public Parameterized(Class<?> klass) throws Throwable {
267268
super(klass, RunnersFactory.createRunnersForClass(klass));
268269
}
269270

271+
@Override
272+
protected void collectInitializationErrors(List<Throwable> errors) {
273+
super.collectInitializationErrors(errors);
274+
validatePublicStaticVoidMethods(Parameterized.BeforeParam.class, errors);
275+
validatePublicStaticVoidMethods(Parameterized.AfterParam.class, errors);
276+
}
277+
278+
private void validatePublicStaticVoidMethods(Class<? extends Annotation> annotation,
279+
List<Throwable> errors) {
280+
final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
281+
for (FrameworkMethod eachTestMethod : methods) {
282+
eachTestMethod.validatePublicVoid(true, errors);
283+
}
284+
}
285+
270286
private static class RunnersFactory {
271287
private static final ParametersRunnerFactory DEFAULT_FACTORY = new BlockJUnit4ClassRunnerWithParametersFactory();
272288

src/main/java/org/junit/runners/parameterized/BlockJUnit4ClassRunnerWithParameters.java

-15
Original file line numberDiff line numberDiff line change
@@ -96,21 +96,6 @@ protected String testName(FrameworkMethod method) {
9696
return method.getName() + getName();
9797
}
9898

99-
@Override
100-
protected void collectInitializationErrors(List<Throwable> errors) {
101-
super.collectInitializationErrors(errors);
102-
validatePublicStaticVoidMethods(Parameterized.BeforeParam.class, errors);
103-
validatePublicStaticVoidMethods(Parameterized.AfterParam.class, errors);
104-
}
105-
106-
private void validatePublicStaticVoidMethods(Class<? extends Annotation> annotation,
107-
List<Throwable> errors) {
108-
final List<FrameworkMethod> methods = getTestClass().getAnnotatedMethods(annotation);
109-
for (FrameworkMethod eachTestMethod : methods) {
110-
eachTestMethod.validatePublicVoid(true, errors);
111-
}
112-
}
113-
11499
@Override
115100
protected void validateConstructor(List<Throwable> errors) {
116101
validateOnlyOneConstructor(errors);

0 commit comments

Comments
 (0)