Java Code Examples for org.junit.runner.RunWith

The following code examples are extracted from open source projects. You can click to vote up the examples that are useful to you.

Example 1

From project JDave, under directory /jdave-junit4/src/java/org/junit/internal/builders/.

Source file: AnnotatedBuilder.java

  18 
vote

@Override public Runner runnerForClass(final Class<?> testClass) throws Exception {
  final RunWith annotation=getRunWithAnnotation(testClass);
  if (annotation != null) {
    return buildRunner(annotation.value(),testClass);
  }
  return null;
}
 

Example 2

From project Core_2, under directory /test-harness-web/src/main/java/org/jboss/forge/test/web/.

Source file: WebTestImpl.java

  15 
vote

@Override public void addAsTestClass(final Project project,final JavaClass clazz){
  try {
    JavaSourceFacet java=project.getFacet(JavaSourceFacet.class);
    clazz.setName(clazz.getName() + "Test").setPackage(java.getBasePackage());
    if (!clazz.hasAnnotation(RunWith.class)) {
      Annotation<JavaClass> runWith=clazz.addAnnotation(RunWith.class);
      runWith.setLiteralValue("Arquillian.class");
    }
    if (clazz.hasAnnotation(Ignore.class)) {
      clazz.removeAnnotation(clazz.getAnnotation(Ignore.class));
    }
    clazz.addImport(Arquillian.class);
    java.saveTestJavaSource(clazz);
  }
 catch (  FileNotFoundException e) {
    throw new RuntimeException(e);
  }
}
 

Example 3

From project JDave, under directory /jdave-junit4/src/java/org/junit/internal/builders/.

Source file: AnnotatedBuilder.java

  15 
vote

private RunWith getRunWithAnnotation(final Class<?> testClass){
  if (testClass.isAnnotationPresent(RunWith.class)) {
    return testClass.getAnnotation(RunWith.class);
  }
  if (testClassIsANonStaticInnerClass(testClass)) {
    return testClass.getDeclaringClass().getAnnotation(RunWith.class);
  }
  return null;
}
 

Example 4

From project kawala, under directory /kawala-testing/src/main/java/com/kaching/platform/testing/.

Source file: TestSuiteBuilder.java

  15 
vote

private boolean hasTests(Class<?> clazz){
  for (  Method method : clazz.getDeclaredMethods()) {
    if (method.getAnnotation(org.junit.Test.class) != null) {
      return true;
    }
  }
  for (  Annotation a : clazz.getAnnotations()) {
    if (a.annotationType().equals(RunWith.class)) {
      return true;
    }
  }
  return false;
}