Search in sources :

Example 36 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project tomee by apache.

the class MetaRunner method collectInitializationErrors.

/**
 * Flags an error if you have annotated a test with both @Test and @Keys. Any method annotated with @Test will be ignored anyways.
 */
@Override
protected void collectInitializationErrors(final List<Throwable> errors) {
    super.collectInitializationErrors(errors);
    final List<FrameworkMethod> methodsAnnotatedWithKeys = getTestClass().getAnnotatedMethods(MetaTest.class);
    for (final FrameworkMethod frameworkMethod : methodsAnnotatedWithKeys) {
        if (frameworkMethod.getAnnotation(Test.class) != null) {
            final String gripe = "The method " + frameworkMethod.getName() + "() can only be annotated with @MetaTest";
            errors.add(new Exception(gripe));
        }
    }
}
Also used : Test(org.junit.Test) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 37 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project tomee by apache.

the class ValidationRunner method collectInitializationErrors.

/**
 * Flags an error if you have annotated a test with both @Test and @Keys. Any method annotated with @Test will be ignored anyways.
 */
@Override
protected void collectInitializationErrors(final List<Throwable> errors) {
    super.collectInitializationErrors(errors);
    final List<FrameworkMethod> methodsAnnotatedWithKeys = getTestClass().getAnnotatedMethods(Keys.class);
    for (final FrameworkMethod frameworkMethod : methodsAnnotatedWithKeys) {
        if (frameworkMethod.getAnnotation(Test.class) != null) {
            final String gripe = "The method " + frameworkMethod.getName() + "() can only be annotated with @Keys";
            errors.add(new Exception(gripe));
        }
    }
}
Also used : Test(org.junit.Test) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 38 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project pravega by pravega.

the class SingleJUnitTestRunner method runMethod.

public void runMethod() {
    Method m = null;
    try {
        m = this.testClass.getDeclaredMethod(this.methodName);
        Statement statement = methodBlock(new FrameworkMethod(m));
        statement.evaluate();
    } catch (Throwable ex) {
        throw new TestFrameworkException(TestFrameworkException.Type.InternalError, "Exception while running test" + " method: " + this.methodName, ex);
    }
}
Also used : TestFrameworkException(io.pravega.test.system.framework.TestFrameworkException) Statement(org.junit.runners.model.Statement) FrameworkMethod(org.junit.runners.model.FrameworkMethod) Method(java.lang.reflect.Method) FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 39 with FrameworkMethod

use of org.junit.runners.model.FrameworkMethod in project gwt-test-utils by gwt-test-utils.

the class GwtSpringJUnitParamsClassRunner method getDescription.

@Override
public Description getDescription() {
    if (description == null) {
        description = Description.createSuiteDescription(getName(), getTestClass().getAnnotations());
        List<FrameworkMethod> resultMethods = parameterisedRunner.returnListOfMethods();
        for (FrameworkMethod method : resultMethods) description.addChild(describeMethod(method));
    }
    return description;
}
Also used : FrameworkMethod(org.junit.runners.model.FrameworkMethod)

Example 40 with FrameworkMethod

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

the class CategoryValidatorTest method errorIsAddedWhenCategoryIsUsedWithBeforeClass.

@Test
public void errorIsAddedWhenCategoryIsUsedWithBeforeClass() {
    FrameworkMethod method = new TestClass(CategoryTest.class).getAnnotatedMethods(BeforeClass.class).get(0);
    testAndAssertErrorMessage(method, "@BeforeClass can not be combined with @Category");
}
Also used : BeforeClass(org.junit.BeforeClass) TestClass(org.junit.runners.model.TestClass) 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