Search in sources :

Example 6 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)

Example 7 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.

the class CategoryValidatorTest method errorIsAddedWhenCategoryIsUsedWithAfterClass.

@Test
public void errorIsAddedWhenCategoryIsUsedWithAfterClass() {
    FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(AfterClass.class).get(0);
    testAndAssertErrorMessage(method, "@AfterClass can not be combined with @Category");
}
Also used : TestClass(org.junit.runners.model.TestClass) FrameworkMethod(org.junit.runners.model.FrameworkMethod) AfterClass(org.junit.AfterClass) Test(org.junit.Test)

Example 8 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.

the class CategoryValidatorTest method errorIsAddedWhenCategoryIsUsedWithAfter.

@Test
public void errorIsAddedWhenCategoryIsUsedWithAfter() {
    FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(After.class).get(0);
    testAndAssertErrorMessage(method, "@After can not be combined with @Category");
}
Also used : After(org.junit.After) TestClass(org.junit.runners.model.TestClass) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Test(org.junit.Test)

Example 9 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project junit4 by junit-team.

the class SpecificDataPointsSupplier method getSingleDataPointMethods.

@Override
protected Collection<FrameworkMethod> getSingleDataPointMethods(ParameterSignature sig) {
    Collection<FrameworkMethod> methods = super.getSingleDataPointMethods(sig);
    String requestedName = sig.getAnnotation(FromDataPoints.class).value();
    List<FrameworkMethod> methodsWithMatchingNames = new ArrayList<FrameworkMethod>();
    for (FrameworkMethod method : methods) {
        String[] methodNames = method.getAnnotation(DataPoint.class).value();
        if (Arrays.asList(methodNames).contains(requestedName)) {
            methodsWithMatchingNames.add(method);
        }
    }
    return methodsWithMatchingNames;
}
Also used : DataPoint(org.junit.experimental.theories.DataPoint) ArrayList(java.util.ArrayList) FromDataPoints(org.junit.experimental.theories.FromDataPoints) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 10 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)

Aggregations

FrameworkMethod (org.junit.runners.model.FrameworkMethod)58 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)9 MethodRule (org.junit.rules.MethodRule)6 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