use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.
the class SpecificDataPointsSupplier method getDataPointsMethods.
@Override
protected Collection<FrameworkMethod> getDataPointsMethods(ParameterSignature sig) {
Collection<FrameworkMethod> methods = super.getDataPointsMethods(sig);
String requestedName = sig.getAnnotation(FromDataPoints.class).value();
List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
for (FrameworkMethod method : methods) {
String[] methodNames = method.getAnnotation(DataPoints.class).value();
if (Arrays.asList(methodNames).contains(requestedName)) {
methodsWithMatchingNames.add(method);
}
}
return methodsWithMatchingNames;
}
use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.
the class RunAfters method evaluate.
@Override
public void evaluate() throws Throwable {
List<Throwable> errors = new ArrayList<Throwable>();
try {
next.evaluate();
} catch (Throwable e) {
errors.add(e);
} finally {
for (FrameworkMethod each : afters) {
try {
each.invokeExplosively(target);
} catch (Throwable e) {
errors.add(e);
}
}
}
MultipleFailureException.assertEmpty(errors);
}
use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.
the class Theories method validateTestMethods.
@Override
protected void validateTestMethods(List<Throwable> errors) {
for (FrameworkMethod each : computeTestMethods()) {
if (each.getAnnotation(Theory.class) != null) {
each.validatePublicVoid(false, errors);
each.validateNoTypeParametersOnArgs(errors);
} else {
each.validatePublicVoidNoArg(false, errors);
}
for (ParameterSignature signature : ParameterSignature.signatures(each.getMethod())) {
ParametersSuppliedBy annotation = signature.findDeepAnnotation(ParametersSuppliedBy.class);
if (annotation != null) {
validateParameterSupplier(annotation.value(), errors);
}
}
}
}
use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.
the class CategoryValidatorTest method errorIsAddedWhenCategoryIsUsedWithBefore.
@Test
public void errorIsAddedWhenCategoryIsUsedWithBefore() {
FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(Before.class).get(0);
testAndAssertErrorMessage(method, "@Before can not be combined with @Category");
}
use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.
the class CategoryValidatorTest method errorIsNotAddedWhenCategoryIsNotCombinedWithIllegalCombination.
@Test
public void errorIsNotAddedWhenCategoryIsNotCombinedWithIllegalCombination() throws NoSuchMethodException {
FrameworkMethod method = new FrameworkMethod(CategoryTest.class.getMethod("methodWithCategory"));
List<Exception> errors = new CategoryValidator().validateAnnotatedMethod(method);
assertThat(errors.size(), is(0));
}
Aggregations