Search in sources :

Example 6 with RunWith

use of org.junit.runner.RunWith in project gradle by gradle.

the class JUnitTestClassExecutor method isNestedClassInsideEnclosedRunner.

// https://github.com/gradle/gradle/issues/2319
public static boolean isNestedClassInsideEnclosedRunner(Class<?> testClass) {
    if (testClass.getEnclosingClass() == null) {
        return false;
    }
    Class<?> outermostClass = testClass;
    while (outermostClass.getEnclosingClass() != null) {
        outermostClass = outermostClass.getEnclosingClass();
    }
    RunWith runWith = outermostClass.getAnnotation(RunWith.class);
    return runWith != null && Enclosed.class.equals(runWith.value());
}
Also used : Enclosed(org.junit.experimental.runners.Enclosed) RunWith(org.junit.runner.RunWith)

Example 7 with RunWith

use of org.junit.runner.RunWith in project hazelcast by hazelcast.

the class IsolatedLoggingRule method ensureSerialRunner.

private void ensureSerialRunner(Description description) {
    RunWith runWithAnnotation = description.getTestClass().getAnnotation(RunWith.class);
    Class runnerClass = runWithAnnotation == null ? null : runWithAnnotation.value();
    if (runnerClass == null || !HazelcastSerialClassRunner.class.isAssignableFrom(runnerClass)) {
        throw new IllegalStateException("Isolated logging may be achieved only when running a test using a serial runner. Use" + " HazelcastSerialClassRunner or its subclass to run this test.");
    }
}
Also used : RunWith(org.junit.runner.RunWith)

Example 8 with RunWith

use of org.junit.runner.RunWith in project sofa-ark by alipay.

the class JUnitExecutionListener method isTestOnArkContainer.

protected boolean isTestOnArkContainer(Description description) {
    RunWith runWith = description.getTestClass().getAnnotation(RunWith.class);
    if (runWith == null) {
        return false;
    }
    Class<?> runnerClass = runWith.value();
    String className = runnerClass.getName();
    return ARK_JUNIT4_RUNNER.equals(className) || ARK_BOOT_RUNNER.equals(className);
}
Also used : RunWith(org.junit.runner.RunWith)

Example 9 with RunWith

use of org.junit.runner.RunWith in project squidb by yahoo.

the class SquidbTestRunner method isJUnit4TestClass.

/**
 * @return true if {@param cls} is {@link JUnit4} annotated.
 */
protected boolean isJUnit4TestClass(Class cls) {
    // Need to find test classes, otherwise crashes with b/11790448.
    if (!cls.getName().endsWith("Test")) {
        return false;
    }
    // Check the annotations.
    Annotation annotation = cls.getAnnotation(RunWith.class);
    if (annotation != null) {
        RunWith runWith = (RunWith) annotation;
        Object value = runWith.value();
        if (value.equals(JUnit4.class) || value.equals(Suite.class)) {
            return true;
        }
    }
    return false;
}
Also used : Suite(org.junit.runners.Suite) RunWith(org.junit.runner.RunWith) Annotation(java.lang.annotation.Annotation) JUnit4(org.junit.runners.JUnit4)

Example 10 with RunWith

use of org.junit.runner.RunWith in project jbehave-core by jbehave.

the class AnnotatedEmbedderUtils method runnerClass.

private static Class<?> runnerClass(String annotatedClassName, EmbedderClassLoader classLoader) {
    Class<?> annotatedClass = loadClass(annotatedClassName, classLoader);
    RunWith annotation = annotatedClass.getAnnotation(RunWith.class);
    if (annotation != null) {
        return annotation.value();
    }
    throw new MissingAnnotatedEmbedderRunner(annotatedClass);
}
Also used : RunWith(org.junit.runner.RunWith)

Aggregations

RunWith (org.junit.runner.RunWith)12 Method (java.lang.reflect.Method)5 List (java.util.List)3 JUnit4 (org.junit.runners.JUnit4)3 IOException (java.io.IOException)2 Annotation (java.lang.annotation.Annotation)2 Modifier (java.lang.reflect.Modifier)2 Arrays (java.util.Arrays)2 Set (java.util.Set)2 Suite (org.junit.runners.Suite)2 Application (cn.edu.zjnu.acm.judge.Application)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Objects (com.google.common.base.Objects)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 Truth.assertThat (com.google.common.truth.Truth.assertThat)1 Gson (com.google.gson.Gson)1 PsiUtils (com.google.idea.blaze.base.lang.buildfile.psi.util.PsiUtils)1 WorkspacePath (com.google.idea.blaze.base.model.primitives.WorkspacePath)1 BlazeRunConfigurationProducerTestCase (com.google.idea.blaze.base.run.producer.BlazeRunConfigurationProducerTestCase)1 Info (com.intellij.execution.lineMarker.RunLineMarkerContributor.Info)1