Stream<Assignment> allPossible() throws Throwable { final List<FrameworkMethod> annotatedMethods = testClass.getAnnotatedMethods(DataProducer.class); Stream<Assignment> methodAssignments = Stream.empty(); for (FrameworkMethod annotatedMethod : annotatedMethods) { final Type methodReturnType = getMethodGenericReturnType(annotatedMethod.getMethod()); methodAssignments = Stream.concat(methodAssignments, methodToStreamOfResults(annotatedMethod) .map(value -> new MethodResultAssignment(value, methodReturnType, annotatedMethod))); } final List<FrameworkField> annotatedFields = testClass.getAnnotatedFields(DataProducer.class); final Stream<Assignment> fieldsAssignments = annotatedFields.stream() .map(FieldAssignment::new); return Stream.concat(fieldsAssignments, methodAssignments); }
/** * Implements behavior from: org.junit.runners.Parameterized$TestClassRunnerForParameters */ private Object createTestUsingFieldInjection() throws Exception { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); if (annotatedFieldsByParameter.size() != fParameters.length) { throw new Exception("Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size() + ", available parameters: " + fParameters.length + "."); } Object testClassInstance = getTestClass().getJavaClass().newInstance(); for (FrameworkField each : annotatedFieldsByParameter) { Field field = each.getField(); Parameter annotation = field.getAnnotation(Parameter.class); int index = annotation.value(); try { field.set(testClassInstance, fParameters[index]); } catch (IllegalArgumentException iare) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " with the value " + fParameters[index] + " that is not the right type (" + fParameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").", iare); } } return testClassInstance; }
private Object injectAnnotatedFields(final Object testInstance) throws Exception { final List<FrameworkField> fields = getFieldsAnnotatedByRef(); final Object[] fieldValues = tableRow.convertValues(fields, defaultValueConverter); for (int i = 0; i < fields.size(); i++) { final Field field = fields.get(i).getField(); try { field.setAccessible(true); field.set(testInstance, fieldValues[i]); } catch (final Exception e) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " with the value " + fieldValues[i], e); } } return testInstance; }
@Override public void evaluate() throws Throwable { Injector injector = getInjector(); for (FrameworkField frameworkField : fields) { Field field = frameworkField.getField(); if (ReflectionUtils.getFieldValue(field, target) != null) { throw new IllegalStateException("Field with @InjectDelayed must be null on startup. " + "Field '" + field.getName() + "' is not null"); } Object object = injector.getSingleton(field.getType()); ReflectionUtils.setField(field, target, object); } this.testClass = null; this.target = null; this.fields = null; next.evaluate(); }
@Test public void shouldInitializeInjectDelayedField() throws Throwable { // given - test class with initialized @Mock fields DelayedInjectionRunnerIntegrationTest runnerTest = new DelayedInjectionRunnerIntegrationTest(); MockitoAnnotations.initMocks(runnerTest); TestClass testClass = new TestClass(runnerTest.getClass()); Statement nextStatement = mock(Statement.class); List<FrameworkField> injectDelayedFields = testClass.getAnnotatedFields(InjectDelayed.class); assertThat(injectDelayedFields, hasSize(1)); // assumption RunDelayedInjects runDelayedInjects = new RunDelayedInjects(nextStatement, testClass, runnerTest, injectDelayedFields); // when runDelayedInjects.evaluate(); // then assertThat(ReflectionUtils.getFieldValue(injectDelayedFields.get(0).getField(), runnerTest), not(nullValue())); verify(nextStatement).evaluate(); }
@Test public void shouldThrowForAlreadyInitializedField() throws Throwable { // given - test class with initialized @Mock fields DelayedInjectionRunnerIntegrationTest runnerTest = new DelayedInjectionRunnerIntegrationTest(); MockitoAnnotations.initMocks(runnerTest); TestClass testClass = new TestClass(runnerTest.getClass()); Statement nextStatement = mock(Statement.class); List<FrameworkField> injectDelayedFields = testClass.getAnnotatedFields(InjectDelayed.class); assertThat(injectDelayedFields, hasSize(1)); // assumption ReflectionUtils.setField(injectDelayedFields.get(0).getField(), runnerTest, mock(SampleInjectClass.class)); RunDelayedInjects runDelayedInjects = new RunDelayedInjects(nextStatement, testClass, runnerTest, injectDelayedFields); // when try { runDelayedInjects.evaluate(); fail("Expected exception to be thrown"); } catch (Exception e) { assertThat(e.getMessage(), containsString("Field with @InjectDelayed must be null")); } }
public List<T> getInjectionTestPoints() throws IllegalAccessException { List<T> result = new ArrayList<>(); List<FrameworkField> fields = getTestClass().getAnnotatedFields(); final MethodHandles.Lookup lookup = MethodHandles.lookup(); for (FrameworkField field : fields) { Field javaField = field.getField(); javaField.setAccessible(true); MethodHandle setter = lookup.unreflectSetter(javaField); T ip = createInjectionPoint(javaField.getType(), javaField.getAnnotations(), setter); result.add(ip); } return result; }
@Override protected void scanAnnotatedMembers(Map<Class<? extends Annotation>,List<FrameworkMethod>> methodsForAnnotations, Map<Class<? extends Annotation>,List<FrameworkField>> fieldsForAnnotations) { super.scanAnnotatedMembers(methodsForAnnotations, fieldsForAnnotations); for (Map.Entry<Class<? extends Annotation>,List<FrameworkMethod>> entry : methodsForAnnotations.entrySet()) { if (Test.class.equals(entry.getKey())) { List<FrameworkMethod> methods = new ArrayList<>(); for (FrameworkMethod method : entry.getValue()) { Method javaMethod = method.getMethod(); if (javaMethod.getParameterTypes().length > 0) { methods.add(new BaratineFrameworkMethod(javaMethod)); } else { methods.add(method); } } entry.setValue(methods); } } }
/** * @see BlockJUnit4ClassRunnerWithParameters#createTestUsingFieldInjection() */ private static Object createTestUsingFieldInjection(TestClass testClass, Object[] parameters) throws Exception { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(testClass); if (annotatedFieldsByParameter.size() != parameters.length) { throw new Exception("Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size() + ", available parameters: " + parameters.length + "."); } Object testClassInstance = testClass.getJavaClass().newInstance(); for (FrameworkField each : annotatedFieldsByParameter) { Field field = each.getField(); Parameterized.Parameter annotation = field.getAnnotation(Parameterized.Parameter.class); int index = annotation.value(); try { field.set(testClassInstance, parameters[index]); } catch (IllegalArgumentException iare) { throw new Exception( testClass.getName() + ": Trying to set " + field.getName() + " with the value " + parameters[index] + " that is not the right type (" + parameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").", iare); } } return testClassInstance; }
/** * Default constructor, called by JUnit. * * @param clazz * The root class of the suite. * @throws InitializationError * If there */ public FuzzyRunner(Class<?> clazz) throws InitializationError { super(clazz, Collections.<Runner> emptyList()); dataProvider = getDataProvider(); dataProvider.setTestClass(getTestClass()); dataProvider.init(); FrameworkField dataField = getDataField(); FrameworkField utilField = getUtilField(); FrameworkField optionsField = getOptionsField(); org.eclipse.emf.emfstore.fuzzy.Util util = dataProvider.getUtil(); for (int i = 0; i < dataProvider.size(); i++) { FuzzyTestClassRunner runner = new FuzzyTestClassRunner(clazz, dataProvider, dataField, utilField, optionsField, util, i + 1); if (runner.getChildren().size() > 0) { runners.add(runner); } } }
private FrameworkField getSingleStaticFrameworkField( Class<? extends Annotation> annotation) { List<FrameworkField> fields = getTestClass().getAnnotatedFields( annotation); // Check if there are more than one Data field in the class if (fields.size() > 1) { throw new RuntimeException("Only one field annotated with " + annotation.getSimpleName() + " permitted: " + getTestClass().getName() + " contains " + fields.size()); } // get the field and check modifiers for (FrameworkField field : fields) { int modifiers = field.getField().getModifiers(); if (!Modifier.isStatic(modifiers)) { return field; } } return null; }
public KurentoTestListener(List<FrameworkField> services) { this.serviceFields = services; for (FrameworkField service : serviceFields) { TestService serviceRunner = null; try { serviceRunner = (TestService) service.getField().get(null); if (!serviceRunners.contains(serviceRunner)) { serviceRunners.add(serviceRunner); if (serviceRunner.getScope() == TESTSUITE) { serviceRunner.start(); } } } catch (Throwable e) { log.warn("Exception instanting service in class {}", serviceRunner, e); } } }
private void doInject(TestClass klass, Object instance) { try { for (FrameworkField frameworkField : klass.getAnnotatedFields(Inject.class)) { Field field = frameworkField.getField(); if ((instance == null && Modifier.isStatic(field.getModifiers()) || instance != null)) {//we want to do injection even on static fields before test run, so we make sure that client is correct for current state of server field.setAccessible(true); if (field.getType() == ManagementClient.class && controller.isStarted()) { field.set(instance, controller.getClient()); } else if (field.getType() == ModelControllerClient.class && controller.isStarted()) { field.set(instance, controller.getClient().getControllerClient()); } else if (field.getType() == ServerController.class) { field.set(instance, controller); } } } } catch (Exception e) { throw new RuntimeException("Failed to inject", e); } }
private Object createTestUsingFieldInjection() throws Exception { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); if (annotatedFieldsByParameter.size() != fParameters.length) { throw new Exception("Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size() + ", available parameters: " + fParameters.length + "."); } Object testClassInstance = getTestClass().getJavaClass().newInstance(); for (FrameworkField each : annotatedFieldsByParameter) { Field field = each.getField(); Parameter annotation = field.getAnnotation(Parameter.class); int index = annotation.value(); try { field.set(testClassInstance, fParameters[index]); } catch (IllegalArgumentException iare) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " with the value " + fParameters[index] + " that is not the right type (" + fParameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").", iare); } } return testClassInstance; }
@Override protected Object createTest() throws Exception { if (fieldAnnotated()) { Object testInstance = getTestClass().getOnlyConstructor().newInstance(); List<FrameworkField> configFields = getFieldsAnnotatedByKiWiConfig(); for (FrameworkField field : configFields) { try { field.getField().set(testInstance, config); } catch (IllegalArgumentException iae) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " that has a wrong type."); } } return testInstance; } return getTestClass().getOnlyConstructor().newInstance(config); }
/** * @return {@code true} if the test class has any fields annotated with {@code Rule} whose type * is {@link Timeout}. */ static boolean hasTimeoutRule(TestClass testClass) { // Many protected convenience methods in BlockJUnit4ClassRunner that are available in JUnit 4.11 // such as getTestRules(Object) were not public until // https://github.com/junit-team/junit/commit/8782efa08abf5d47afdc16740678661443706740, // which appears to be JUnit 4.9. Because we allow users to use JUnit 4.7, we need to include a // custom implementation that is backwards compatible to JUnit 4.7. List<FrameworkField> fields = testClass.getAnnotatedFields(Rule.class); for (FrameworkField field : fields) { if (field.getField().getType().equals(Timeout.class)) { return true; } } return false; }
@Override protected void configure() { final Errors errors = new Errors(testClass); for (FrameworkField field : fields) { try { final Field f = field.getField(); final Key key = Annotations.getKey(TypeLiteral.get(f.getGenericType()), f, field.getAnnotations(), errors); bindMock(key, f.getType(), "Automock[" + field.getName() + "] " + key); } catch (ErrorsException e) { // Add it to the error list and hold them all until the end errors.merge(e.getErrors()); } } errors.throwConfigurationExceptionIfErrorsExist(); }
/** * @return {@code true} if the test class has any fields annotated with {@code Rule} whose type is * {@link Timeout}. */ static boolean hasTimeoutRule(TestClass testClass) { // Many protected convenience methods in BlockJUnit4ClassRunner that are available in JUnit 4.11 // such as getTestRules(Object) were not public until // https://github.com/junit-team/junit/commit/8782efa08abf5d47afdc16740678661443706740, // which appears to be JUnit 4.9. Because we allow users to use JUnit 4.7, we need to include a // custom implementation that is backwards compatible to JUnit 4.7. List<FrameworkField> fields = testClass.getAnnotatedFields(Rule.class); for (FrameworkField field : fields) { if (field.getField().getType().equals(Timeout.class)) { return true; } } return false; }
/** * Implements behavior from: org.junit.runners.Parameterized$TestClassRunnerForParameters */ @Override protected void validateFields(List<Throwable> errors) { super.validateFields(errors); if (fieldsAreAnnotated()) { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); int[] usedIndices = new int[annotatedFieldsByParameter.size()]; for (FrameworkField each : annotatedFieldsByParameter) { int index = each.getField().getAnnotation(Parameter.class).value(); if (index < 0 || index > annotatedFieldsByParameter.size() - 1) { errors.add(new Exception("Invalid @Parameter value: " + index + ". @Parameter fields counted: " + annotatedFieldsByParameter.size() + ". Please use an index between 0 and " + (annotatedFieldsByParameter.size() - 1) + ".")); } else { usedIndices[index]++; } } for (int index = 0; index < usedIndices.length; index++) { int numberOfUse = usedIndices[index]; if (numberOfUse == 0) { errors.add(new Exception("@Parameter(" + index + ") is never used.")); } else if (numberOfUse > 1) { errors.add(new Exception("@Parameter(" + index + ") is used more than once (" + numberOfUse + ").")); } } } }
@Override protected void validateFields(List<Throwable> errors) { super.validateFields(errors); if (fieldsAreAnnotated()) { final List<FrameworkField> fields = getFieldsAnnotatedByRef(); for (final FrameworkField field : fields) { final String refName = field.getField().getAnnotation(Spockito.Ref.class).value(); if (!tableRow.isValidRefName(refName)) { errors.add(new Exception("Invalid @Ref value: " + refName + " does not reference a column of the table defined by @Unroll")); } } } }
public Object[] convertValues(final List<FrameworkField> fields, final ValueConverter valueConverter) { final Object[] converted = new Object[fields.size()]; for (int i = 0; i < converted.length; i++) { final Field field = fields.get(i).getField(); final String refValue = fields.get(i).getAnnotation(Spockito.Ref.class).value(); final String refName = refValue.isEmpty() ? field.getName() : refValue; converted[i] = convertValue(refName, -1, field.getType(), field.getGenericType(), valueConverter); } return converted; }
private Collection<ArchTestExecution> findArchRuleFields() { List<ArchTestExecution> result = new ArrayList<>(); for (FrameworkField ruleField : getTestClass().getAnnotatedFields(ArchTest.class)) { result.addAll(findArchRulesIn(ruleField)); } return result; }
private Set<ArchTestExecution> findArchRulesIn(FrameworkField ruleField) { if (ruleField.getType() == ArchRules.class) { boolean ignore = elementShouldBeIgnored(ruleField.getField()); return getArchRules(ruleField).asTestExecutions(ignore); } return Collections.<ArchTestExecution>singleton(new ArchRuleExecution(getTestClass().getJavaClass(), ruleField.getField(), false)); }
private ArchRules getArchRules(FrameworkField ruleField) { ArchTestExecution.validatePublicStatic(ruleField.getField()); try { return (ArchRules) ruleField.get(null); } catch (IllegalAccessException e) { throw new RuntimeException(e); } }
@Nullable private Object resolveByAnnotation(Class<? extends Annotation> annotation, Class<?> type) { if (!ignoredAnnotations.contains(annotation)) { List<FrameworkField> fields = testClass.getAnnotatedFields(annotation); for (FrameworkField field : fields) { if (type.isAssignableFrom(field.getType())) { return ReflectionUtils.getFieldValue(field.getField(), target); } } } return null; }
private Object createTestUsingFieldInjection() throws Exception { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); if (annotatedFieldsByParameter.size() != parameters.length) { throw new Exception( "Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size() + ", available parameters: " + parameters.length + "."); } Object testClassInstance = getTestClass().getJavaClass().newInstance(); for (FrameworkField each : annotatedFieldsByParameter) { Field field = each.getField(); Parameter annotation = field.getAnnotation(Parameter.class); int index = annotation.value(); try { field.set(testClassInstance, parameters[index]); } catch (IllegalArgumentException iare) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " with the value " + parameters[index] + " that is not the right type (" + parameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").", iare); } } return testClassInstance; }
@Override protected void validateFields(List<Throwable> errors) { super.validateFields(errors); if (getInjectionType() == InjectionType.FIELD) { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); int[] usedIndices = new int[annotatedFieldsByParameter.size()]; for (FrameworkField each : annotatedFieldsByParameter) { int index = each.getField().getAnnotation(Parameter.class) .value(); if (index < 0 || index > annotatedFieldsByParameter.size() - 1) { errors.add(new Exception("Invalid @Parameter value: " + index + ". @Parameter fields counted: " + annotatedFieldsByParameter.size() + ". Please use an index between 0 and " + (annotatedFieldsByParameter.size() - 1) + ".")); } else { usedIndices[index]++; } } for (int index = 0; index < usedIndices.length; index++) { int numberOfUse = usedIndices[index]; if (numberOfUse == 0) { errors.add(new Exception("@Parameter(" + index + ") is never used.")); } else if (numberOfUse > 1) { errors.add(new Exception("@Parameter(" + index + ") is used more than once (" + numberOfUse + ").")); } } } }
public JpaUnitRunner(final Class<?> clazz) throws InitializationError { super(clazz); executor = new DecoratorExecutor(); final List<FrameworkField> ruleFields = getTestClass().getAnnotatedFields(Rule.class); if (ruleFields.stream().anyMatch(f -> f.getType().equals(JpaUnitRule.class))) { throw new InitializationError("JpaUnitRunner and JpaUnitRule exclude each other"); } }
/** * @param test the test class * @return the MethodRules that can transform the block * that runs each method in the tested class. */ protected List<MethodRule> rules( Object test ) { List<MethodRule> results = new ArrayList<MethodRule>(); for( FrameworkField each : ruleFields() ) results.add( createRule( test, each ) ); return results; }
private MethodRule createRule( Object test, FrameworkField each ) { try { return (MethodRule) each.get( test ); } catch( IllegalAccessException e ) { throw new RuntimeException( "How did getFields return a field we couldn't access?" ); } catch( IllegalArgumentException ex ) { throw new RuntimeException( "How did getFields return a field we couldn't access?" ); } }
public SharedBehaviorTesting( Function<RunNotifier, Statement> superChildrenInvoker, BiConsumer<FrameworkMethod, RunNotifier> superChildRunner, TestSupplier superCreateTest, Supplier<Description> superDescription, Supplier<TestClass> testClass, BiFunction<Class<?>, String, Description> descriptionFactory, FeatureSet features) throws InitializationError { this.superChildrenInvoker = superChildrenInvoker; this.superChildRunner = superChildRunner; this.superCreateTest = superCreateTest; this.superDescription = superDescription; this.features = features; List<FrameworkField> testerFields = testClass.get().getAnnotatedFields(Shared.class); if (testerFields.isEmpty()) { throw new InitializationError("No public @Shared field found"); } else if (testerFields.size() > 1) { throw new InitializationError("Multiple public @Shared fields found"); } FrameworkField frameworkField = getOnlyElement(testerFields); if (!frameworkField.isPublic()) { throw new InitializationError("@Shared field " + frameworkField + " must be public"); } if (!frameworkField.getType().isAssignableFrom(BehaviorTester.class)) { throw new InitializationError(String.format( "@Shared field %s must be of type %s", frameworkField, BehaviorTester.class.getSimpleName())); } testerField = frameworkField.getField(); introspection = descriptionFactory.apply(testClass.get().getJavaClass(), "Introspect"); }
private AuthorizationRule getAuthorizationRule(TestClass testClass, Object target) throws IllegalAccessException { List<FrameworkField> ruleFields = testClass.getAnnotatedFields(Rule.class); for (FrameworkField ruleField : ruleFields) { if (ruleField.getType().isAssignableFrom(AuthorizationRule.class)) { return (AuthorizationRule) ruleField.get(target); } } throw new IllegalStateException("Test class must have AuthorizationRule set"); }
private Object createTestUsingFieldInjection() throws Exception { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); if (annotatedFieldsByParameter.size() != parameters.length) { throw new Exception( "Wrong number of parameters and @Parameter fields." + " @Parameter fields counted: " + annotatedFieldsByParameter.size() + ", available parameters: " + parameters.length + "."); } Object testClassInstance = getTestClass().getJavaClass().newInstance(); for (FrameworkField each : annotatedFieldsByParameter) { Field field = each.getField(); Parameterized.Parameter annotation = field.getAnnotation(Parameterized.Parameter.class); int index = annotation.value(); try { field.set(testClassInstance, parameters[index]); } catch (IllegalArgumentException iare) { throw new Exception(getTestClass().getName() + ": Trying to set " + field.getName() + " with the value " + parameters[index] + " that is not the right type (" + parameters[index].getClass().getSimpleName() + " instead of " + field.getType().getSimpleName() + ").", iare); } } return testClassInstance; }
@Override protected void validateFields(List<Throwable> errors) { super.validateFields(errors); if (fieldsAreAnnotated()) { List<FrameworkField> annotatedFieldsByParameter = getAnnotatedFieldsByParameter(); int[] usedIndices = new int[annotatedFieldsByParameter.size()]; for (FrameworkField each : annotatedFieldsByParameter) { int index = each.getField().getAnnotation(Parameterized.Parameter.class) .value(); if (index < 0 || index > annotatedFieldsByParameter.size() - 1) { errors.add(new Exception("Invalid @Parameter value: " + index + ". @Parameter fields counted: " + annotatedFieldsByParameter.size() + ". Please use an index between 0 and " + (annotatedFieldsByParameter.size() - 1) + ".")); } else { usedIndices[index]++; } } for (int index = 0; index < usedIndices.length; index++) { int numberOfUse = usedIndices[index]; if (numberOfUse == 0) { errors.add(new Exception("@Parameter(" + index + ") is never used.")); } else if (numberOfUse > 1) { errors.add(new Exception("@Parameter(" + index + ") is used more than once (" + numberOfUse + ").")); } } } }
/** * {@link ParameterizedClassRule}が設定されているフィールドまたはメソッドをチェックします。 * * @param errors エラーのリスト。チェックした結果エラーがあった場合、このリストに追加される */ protected void validateParameterizedClassRules(List<Throwable> errors) { for (FrameworkMethod method : getTestClass().getAnnotatedMethods(ParameterizedClassRule.class)) { if (!method.isStatic()) { errors.add(new Exception("Method " + method.getName() + "() should be static")); } if (!method.isPublic()) { errors.add(new Exception("Method " + method.getName() + "() should be public")); } if (method.getMethod().getParameterTypes().length != 0) { errors.add(new Exception("Method " + method.getName() + "() should have no parameters")); } if (!ParameterizedTestRule.class.isAssignableFrom(method.getType())) { errors.add(new Exception("Method " + method.getName() + "() must return an implementation of ParameterizedTestRule")); } } for (FrameworkField field : getTestClass().getAnnotatedFields(ParameterizedClassRule.class)) { if (!field.isStatic()) { errors.add(new Exception("Field " + field.getName() + " should be static")); } if (!field.isPublic()) { errors.add(new Exception("Field " + field.getName() + " should be public")); } if (!ParameterizedTestRule.class.isAssignableFrom(field.getType())) { errors.add(new Exception("Field " + field.getName() + " must implement ParameterizedTestRule")); } } }
protected Collection<Field> getSingleDataPointFields(ParameterSignature sig) { List<FrameworkField> fields = fClass.getAnnotatedFields(DataPoint.class); Collection<Field> validFields = new ArrayList<Field>(); for (FrameworkField frameworkField : fields) { validFields.add(frameworkField.getField()); } return validFields; }
protected Collection<Field> getDataPointsFields(ParameterSignature sig) { List<FrameworkField> fields = fClass.getAnnotatedFields(DataPoints.class); Collection<Field> validFields = new ArrayList<Field>(); for (FrameworkField frameworkField : fields) { validFields.add(frameworkField.getField()); } return validFields; }