Package org.apache.tools.ant.taskdefs.optional.junit

Examples of org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter


      // may never happen
      e.printStackTrace();
    }
    result.addListener(xmlResultFormatter);
    // create a result formatter that prints to the console
    final JUnitResultFormatter consoleResultFormatter = new BriefJUnitResultFormatter();
    consoleResultFormatter.setOutput(System.out);
    result.addListener(consoleResultFormatter);

    // add the actual tests to the test suite
    Collection collection = new ArrayList();
    collection.add(SelfDiscoveryTest.class);
    for (Iterator iterator = collection.iterator(); iterator.hasNext();) {
      Class clazz = (Class) iterator.next();
      // run all methods starting with "test*"
      Method[] methods = clazz.getMethods();
      for (int i = 0; i < methods.length; i++) {
        if (methods[i].getName().startsWith("test")) {
          TestCase testCase;
          try {
            testCase = (TestCase) clazz.newInstance();
            testCase.setName(methods[i].getName());
            suite.addTest(testCase);
          } catch (InstantiationException e) {
            // may never happen
            e.printStackTrace();
          } catch (IllegalAccessException e) {
            // may never happen
            e.printStackTrace();
          }
        }
      }
    }
   
    // prepare to run tests
    final long start = System.currentTimeMillis();
    xmlResultFormatter.startTestSuite(jUnitTest);
    consoleResultFormatter.startTestSuite(jUnitTest);
   
      // run tests
    suite.run(result);
     
    // write stats and close reultformatter
    jUnitTest.setCounts(result.runCount(), result.failureCount(), result.errorCount());
      jUnitTest.setRunTime(System.currentTimeMillis() - start);
    xmlResultFormatter.endTestSuite(jUnitTest);
    consoleResultFormatter.endTestSuite(jUnitTest);
   
    // print success of failure
    if (result.wasSuccessful()) {
      System.exit(0);
    } else {
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.optional.junit.BriefJUnitResultFormatter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.