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());
}
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.");
}
}
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);
}
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;
}
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);
}
Aggregations