title: JUnit Ant task won't output to screen
body: <h3>Context</h3>
  <p>I am using <a href="http://api.dpml.net/ant/1.7.0/" rel="noreferrer"><code>ant1-9-0.jar</code></a>, <a href="http://www.docjar.com/docs/api/org/apache/tools/ant/taskdefs/optional/junit/package-index.html" rel="noreferrer"><code>ant-junit-1.9.0.jar</code></a> and <code>ant-launcher-1.9.0.jar</code> to run JUnit tests programmatically.</p>
  <p>In my code, I have this function that returns the <a href="http://javadoc.haefelinger.it/org.apache.ant/1.7.1/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.html" rel="noreferrer">JUnit Task</a>:</p>
  <pre><code>/**
   * Generates a JUnit task which runs every single test in a new JVM
   * @return task The JUnit task
   * @throws Exception
   */
  public JUnitTask generateRunTestsTask() throws Exception {
      /* New JUnit task */
      JUnitTask task = new JUnitTask();
      task.init();
      
      /* Summary settings */
      JUnitTask.SummaryAttribute sa = new JUnitTask.SummaryAttribute();
      sa.setValue(&quot;withOutAndErr&quot;);
      task.setPrintsummary(sa);
      
      /* JVM configuration */
      task.setFork(true);
      task.setDir(new File(this.deliveryBinDir));
      task.createJvmarg().setValue(&quot;-Duser.dir=&quot; + this.deliveryBinDir);
      
      /* Output to file */
      FormatterElement.TypeAttribute typeFile = new FormatterElement.TypeAttribute();
      typeFile.setValue(&quot;xml&quot;);
      FormatterElement formatToFile = new FormatterElement();
      formatToFile.setType(typeFile);
      task.addFormatter(formatToFile);
      
      /* Task options */
      task.setHaltonfailure(false);
      task.setShowOutput(true);
      task.setOutputToFormatters(true);
      
      List&lt;String&gt; testSuites = getTestJarList(this.deliveryLibFolder);
      for (String singleSuite : testSuites) {
          JUnitTest test = new JUnitTest(singleSuite);
          /* Sets reports location */
          test.setTodir(this.testReportsFolder);
          task.addTest(test);
      }
      
      return task;
  }
  </code></pre>
  <p>The JUnit tests run without problem and the output is successfully stored into <code>.xml</code> files.</p>
  <h3>Issue</h3>
  <p>I need to print the output to the console, because I want results in live (not only at the end of the whole process). To do so, I have added a second <a href="http://sepp.oetiker.ch/ant-1.6.5-rp/manual/api/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.html" rel="noreferrer"><code>FormatterElement</code></a> just below the <code>/** Output to file */</code> block:</p>
  <pre><code>/* Output to screen */
  FormatterElement.TypeAttribute typeScreen = new FormatterElement.TypeAttribute();
  typeScreen.setValue(&quot;plain&quot;);
  FormatterElement formatToScreen = new FormatterElement();
  formatToScreen.setType(typeScreen);
  formatToScreen.setUseFile(false);
  formatToScreen.setOutput(System.out);
  task.addFormatter(formatToScreen);
  </code></pre>
  <p>But my console still doesn't display the logs. I have also tried to remove the <code>formatToFile</code> <code>FormatterElement</code>, without success. Do you have any suggestions?</p>
  <h3>Notes:</h3>
  <ul>
  <li>these unit tests really need to be forked, it can't be changed,</li>
  <li>just let me know if you need more code, for example the settings of the <a href="http://api.dpml.net/ant/1.7.0/org/apache/tools/ant/Project.html" rel="noreferrer">Ant Project</a> or the <a href="http://javadoc.haefelinger.it/org.apache.ant/1.7.1/org/apache/tools/ant/Target.html" rel="noreferrer">Ant Target</a>,</li>
  <li>unit tests indeed contain <code>Sysouts</code>,</li>
  <li>I've reproduced a consistent <code>build.xml</code> file which works,</li>
  <li><a href="http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/junit" rel="noreferrer">here</a> is the Apache Ant JUnit repository if needed.</li>
  </ul>