From 409b0917b6f737faf5c8b804fdbec8bd1f7f5274 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig
Date: Thu, 14 Sep 2000 08:13:06 +0000
Subject: [PATCH] Added usefile attribute to to allow testoutput to
be sent to stdout instead of a file.
git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267989 13f79535-47bb-0310-9956-ffa450edef68
---
build.xml | 4 +-
docs/junit.html | 13 +++--
.../optional/junit/FormatterElement.java | 11 ++++-
.../taskdefs/optional/junit/JUnitTask.java | 49 ++++++++++++++-----
4 files changed, 60 insertions(+), 17 deletions(-)
diff --git a/build.xml b/build.xml
index 348393211..fe932306b 100644
--- a/build.xml
+++ b/build.xml
@@ -315,7 +315,9 @@
-
+
+
+
diff --git a/docs/junit.html b/docs/junit.html
index fe8d16036..c17d761db 100644
--- a/docs/junit.html
+++ b/docs/junit.html
@@ -91,9 +91,10 @@ href="index.html#arg">Command line arguments.
formatter
The results of the tests can be printed in different
-formats. Output will always be sent to a file, the name of the file is
-determined by the name of the test and can be set by the
-outfile
attribute of <test>
.
+formats. Output will always be sent to a file unless you set the
+usefile attribute to false, the name of the file is determined by the
+name of the test and can be set by the outfile
attribute
+of <test>
.
There are two predefined formatters, one prints the test results in
XML format, the other emits plain text. Custom formatters that need to
@@ -121,6 +122,12 @@ can be specified.
Extension to append to the output filename. |
Yes, if classname has been used. |
+
+ usefile |
+ Boolean that determines whether output should be
+ sent to a file. |
+ No, default true. |
+
test
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
index f2103329c..c1a346600 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/FormatterElement.java
@@ -73,6 +73,7 @@ public class FormatterElement {
private String extension;
private OutputStream out = System.out;
private File outFile;
+ private boolean useFile = true;
public void setType(TypeAttribute type) {
if ("xml".equals(type.getValue())) {
@@ -108,6 +109,14 @@ public class FormatterElement {
this.out = out;
}
+ public void setUseFile(boolean useFile) {
+ this.useFile = useFile;
+ }
+
+ boolean getUseFile() {
+ return useFile;
+ }
+
JUnitResultFormatter createFormatter() throws BuildException {
if (classname == null) {
throw new BuildException("you must specify type or classname");
@@ -135,7 +144,7 @@ public class FormatterElement {
JUnitResultFormatter r = (JUnitResultFormatter) o;
- if (outFile != null) {
+ if (useFile && outFile != null) {
try {
out = new FileOutputStream(outFile);
} catch (java.io.IOException e) {
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
index 7df1e5592..22da24538 100644
--- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
+++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java
@@ -193,6 +193,9 @@ public class JUnitTask extends Task {
}
int exitValue = JUnitTestRunner.ERRORS;
+
+ System.err.println(test.getFork());
+
if (!test.getFork()) {
JUnitTestRunner runner =
new JUnitTestRunner(test, test.getHaltonerror(),
@@ -208,14 +211,22 @@ public class JUnitTask extends Task {
for (int i=0; i