Search in sources :

Example 11 with FrameworkMethod

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;
}
Also used : ArrayList(java.util.ArrayList) DataPoints(org.junit.experimental.theories.DataPoints) FromDataPoints(org.junit.experimental.theories.FromDataPoints) FromDataPoints(org.junit.experimental.theories.FromDataPoints) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 12 with FrameworkMethod

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);
}
Also used : ArrayList(java.util.ArrayList) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 13 with FrameworkMethod

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);
            }
        }
    }
}
Also used : FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 14 with FrameworkMethod

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");
}
Also used : Before(org.junit.Before) TestClass(org.junit.runners.model.TestClass) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Test(org.junit.Test)

Example 15 with FrameworkMethod

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));
}
Also used : CategoryValidator(org.junit.experimental.categories.CategoryValidator) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Test(org.junit.Test)

Aggregations

FrameworkMethod (org.junit.runners.model.FrameworkMethod)59 ArrayList (java.util.ArrayList)15 Statement (org.junit.runners.model.Statement)13 TestClass (org.junit.runners.model.TestClass)13 Test (org.junit.Test)11 Method (java.lang.reflect.Method)10 MethodRule (org.junit.rules.MethodRule)5 Fail (org.junit.internal.runners.statements.Fail)4 RunBefores (org.junit.internal.runners.statements.RunBefores)4 TestRule (org.junit.rules.TestRule)4 Parameterized (org.junit.runners.Parameterized)3 Interaction (au.com.dius.pact.model.Interaction)2 ConsumerInfo (au.com.dius.pact.provider.ConsumerInfo)2 ProviderInfo (au.com.dius.pact.provider.ProviderInfo)2 ProviderVerifier (au.com.dius.pact.provider.ProviderVerifier)2 Provider (au.com.dius.pact.provider.junit.Provider)2 TargetRequestFilter (au.com.dius.pact.provider.junit.TargetRequestFilter)2 BounceMemberRule (com.hazelcast.test.bounce.BounceMemberRule)2 EmptyStatement (com.hazelcast.util.EmptyStatement)2 URL (java.net.URL)2