Exemplo n.º 1
0
  public boolean run() throws IOException {
    try {
      m_dir = "testout/junit-" + m_timestamp + "/" + m_testClazz.getCanonicalName() + "/";
      new File(m_dir).mkdirs();

      // redirect std out/err to files
      m_out.addOutputStream(new File(m_dir + "fulloutput.txt"));
      System.setOut(new PrintStream(m_out, true));
      System.setErr(new PrintStream(m_out, true));

      JUnitCore junit = new JUnitCore();
      junit.addListener(this);
      Result r = junit.run(m_testClazz);
      STDOUT.printf("RESULTS: %d/%d\n", r.getRunCount() - r.getFailureCount(), r.getRunCount());
      return true;
    } catch (Exception e) {
      return false;
    } finally {
      m_out.flush();
      System.setOut(STDOUT);
      System.setErr(STDERR);
      m_out.close();
    }
  }
Exemplo n.º 2
0
 @Override
 public void testStarted(Description description) throws Exception {
   STDOUT.println("STARTED: " + description.getMethodName());
   m_out.addOutputStream(new File(m_dir + description.getMethodName() + ".txt"));
 }
Exemplo n.º 3
0
 @Override
 public void testFinished(Description description) throws Exception {
   STDOUT.println("FINISHED: " + description.getMethodName());
   m_out.removeOutputStream(new File(m_dir + description.getMethodName() + ".txt"));
 }