git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@805415 13f79535-47bb-0310-9956-ffa450edef68master
@@ -847,6 +847,10 @@ Other changes: | |||||
<javac>. | <javac>. | ||||
Bugzilla Report 24359. | Bugzilla Report 24359. | ||||
* It is now possible to suppress the "FAILED" lines sent to Ant's | |||||
logging system via <junit>'s new logFailedTests attribute. | |||||
Bugzilla Report 35073. | |||||
Changes from Ant 1.7.0 TO Ant 1.7.1 | Changes from Ant 1.7.0 TO Ant 1.7.1 | ||||
============================================= | ============================================= | ||||
@@ -228,6 +228,16 @@ elements</a>).</p> | |||||
<em>since Ant 1.7</em></td> | <em>since Ant 1.7</em></td> | ||||
<td align="center" valign="top">No</td> | <td align="center" valign="top">No</td> | ||||
</tr> | </tr> | ||||
<tr> | |||||
<td valign="top">logfailedtests</td> | |||||
<td valign="top">When Ant executes multiple tests and doesn't stop | |||||
on errors or failures it will log a "FAILED" message for each | |||||
failing test to its logging system. If you set this option to | |||||
false, the message will not be logged and you have to rely on the | |||||
formatter output to find the failing tests. | |||||
<em>since Ant 1.8.0</em></td> | |||||
<td align="center" valign="top">No</td> | |||||
</tr> | |||||
</table> | </table> | ||||
<p>By using the <code>errorproperty</code> and <code>failureproperty</code> | <p>By using the <code>errorproperty</code> and <code>failureproperty</code> | ||||
@@ -35,4 +35,5 @@ public class Constants { | |||||
static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents="; | static final String LOGTESTLISTENEREVENTS = "logtestlistenerevents="; | ||||
static final String TESTSFILE = "testsfile="; | static final String TESTSFILE = "testsfile="; | ||||
static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; | static final String TERMINATED_SUCCESSFULLY = "terminated successfully"; | ||||
static final String LOG_FAILED_TESTS="logfailedtests="; | |||||
} | } |
@@ -155,6 +155,8 @@ public class JUnitTask extends Task { | |||||
// Do we send output to the formatters ? | // Do we send output to the formatters ? | ||||
private boolean outputToFormatters = true; | private boolean outputToFormatters = true; | ||||
private boolean logFailedTests = true; | |||||
private File tmpDir; | private File tmpDir; | ||||
private AntClassLoader classLoader = null; | private AntClassLoader classLoader = null; | ||||
private Permissions perm = null; | private Permissions perm = null; | ||||
@@ -596,6 +598,16 @@ public class JUnitTask extends Task { | |||||
this.outputToFormatters = outputToFormatters; | this.outputToFormatters = outputToFormatters; | ||||
} | } | ||||
/** | |||||
* If true, write a single "FAILED" line for failed tests to Ant's | |||||
* log system. | |||||
* | |||||
* @since Ant 1.8.0 | |||||
*/ | |||||
public void setLogFailedTests(boolean logFailedTests) { | |||||
this.logFailedTests = logFailedTests; | |||||
} | |||||
/** | /** | ||||
* Assertions to enable in this program (if fork=true) | * Assertions to enable in this program (if fork=true) | ||||
* @since Ant 1.6 | * @since Ant 1.6 | ||||
@@ -949,6 +961,8 @@ public class JUnitTask extends Task { | |||||
+ String.valueOf(showOutput)); | + String.valueOf(showOutput)); | ||||
cmd.createArgument().setValue(Constants.OUTPUT_TO_FORMATTERS | cmd.createArgument().setValue(Constants.OUTPUT_TO_FORMATTERS | ||||
+ String.valueOf(outputToFormatters)); | + String.valueOf(outputToFormatters)); | ||||
cmd.createArgument().setValue(Constants.LOG_FAILED_TESTS | |||||
+ String.valueOf(logFailedTests)); | |||||
cmd.createArgument().setValue( | cmd.createArgument().setValue( | ||||
Constants.LOGTESTLISTENEREVENTS + "true"); // #31885 | Constants.LOGTESTLISTENEREVENTS + "true"); // #31885 | ||||
@@ -1865,9 +1879,12 @@ public class JUnitTask extends Task { | |||||
+ (result.timedOut ? " (timeout)" : "") | + (result.timedOut ? " (timeout)" : "") | ||||
+ (result.crashed ? " (crashed)" : ""), getLocation()); | + (result.crashed ? " (crashed)" : ""), getLocation()); | ||||
} else { | } else { | ||||
log(name + " FAILED" | |||||
+ (result.timedOut ? " (timeout)" : "") | |||||
+ (result.crashed ? " (crashed)" : ""), Project.MSG_ERR); | |||||
if (logFailedTests) { | |||||
log(name + " FAILED" | |||||
+ (result.timedOut ? " (timeout)" : "") | |||||
+ (result.crashed ? " (crashed)" : ""), | |||||
Project.MSG_ERR); | |||||
} | |||||
if (errorOccurredHere && test.getErrorProperty() != null) { | if (errorOccurredHere && test.getErrorProperty() != null) { | ||||
getProject().setNewProperty(test.getErrorProperty(), "true"); | getProject().setNewProperty(test.getErrorProperty(), "true"); | ||||
} | } | ||||
@@ -680,6 +680,7 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
Properties props = new Properties(); | Properties props = new Properties(); | ||||
boolean showOut = false; | boolean showOut = false; | ||||
boolean outputToFormat = true; | boolean outputToFormat = true; | ||||
boolean logFailedTests = true; | |||||
boolean logTestListenerEvents = false; | boolean logTestListenerEvents = false; | ||||
@@ -723,6 +724,9 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
} else if (args[i].startsWith(Constants.OUTPUT_TO_FORMATTERS)) { | } else if (args[i].startsWith(Constants.OUTPUT_TO_FORMATTERS)) { | ||||
outputToFormat = Project.toBoolean( | outputToFormat = Project.toBoolean( | ||||
args[i].substring(Constants.OUTPUT_TO_FORMATTERS.length())); | args[i].substring(Constants.OUTPUT_TO_FORMATTERS.length())); | ||||
} else if (args[i].startsWith(Constants.LOG_FAILED_TESTS)) { | |||||
logFailedTests = Project.toBoolean( | |||||
args[i].substring(Constants.LOG_FAILED_TESTS.length())); | |||||
} | } | ||||
} | } | ||||
@@ -764,8 +768,10 @@ public class JUnitTestRunner implements TestListener, JUnitTaskMirror.JUnitTestR | |||||
if (code > returnCode) { | if (code > returnCode) { | ||||
returnCode = code; | returnCode = code; | ||||
} | } | ||||
System.out.println("TEST " + t.getName() | |||||
+ " FAILED"); | |||||
if (logFailedTests) { | |||||
System.out.println("TEST " + t.getName() | |||||
+ " FAILED"); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||