Beispiel #1
0
 private Class<?> getMalformedTestClass(Description each) {
   try {
     return Class.forName(each.toString().replace(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX, ""));
   } catch (ClassNotFoundException e) {
     return null;
   }
 }
 @Override
 public String toString() {
   if (mDelegate != null) {
     return mDelegate.toString();
   } else {
     return mDesc.toString();
   }
 }
Beispiel #3
0
 private Runner buildRunner(Description each) {
   if (each.toString().equals("TestSuite with 0 tests")) {
     return Suite.emptySuite();
   }
   if (each.toString().startsWith(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX)) {
     // This is cheating, because it runs the whole class
     // to get the warning for this method, but we can't do better,
     // because JUnit 3.8's
     // thrown away which method the warning is for.
     return new JUnit38ClassRunner(new TestSuite(getMalformedTestClass(each)));
   }
   Class<?> type = each.getTestClass();
   if (type == null) {
     throw new RuntimeException("Can't build a runner from description [" + each + "]");
   }
   String methodName = each.getMethodName();
   if (methodName == null) {
     return Request.aClass(type).getRunner();
   }
   return Request.method(type, methodName).getRunner();
 }
Beispiel #4
0
 private void findLeaves(Description parent, Description description, List<Description> results) {
   if (description.getChildren().isEmpty()) {
     if (description.toString().equals("warning(junit.framework.TestSuite$1)")) {
       results.add(
           Description.createSuiteDescription(MALFORMED_JUNIT_3_TEST_CLASS_PREFIX + parent));
     } else {
       results.add(description);
     }
   } else {
     for (Description each : description.getChildren()) {
       findLeaves(description, each, results);
     }
   }
 }
 @Override
 protected void starting(Description description) {
   LOG.info("executing test {}", description.toString());
 }