Browse Source

Log tests that have timed out in the summary as well.

PR: 23160
Submitted by:	Martijn Kruithof <ant at kruithof dot xs4all dot nl>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275244 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 21 years ago
parent
commit
388c987ddc
1 changed files with 27 additions and 15 deletions
  1. +27
    -15
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 27
- 15
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -1118,26 +1118,38 @@ public class JUnitTask extends Task {
if (outFile != null && formatter != null) {
try {
OutputStream out = new FileOutputStream(outFile);
formatter.setOutput(out);
formatter.startTestSuite(test);
test.setCounts(0, 0, 1);
Test t = new Test() {
public int countTestCases() { return 0; }
public void run(TestResult r) {
throw new AssertionFailedError("Timeout occurred");
}
};
formatter.startTest(t);
formatter
.addError(t,
new AssertionFailedError("Timeout occurred"));

formatter.endTestSuite(test);
addTimeout(test, formatter, out);
} catch (IOException e) {
// ignore
}
}
}
if (summary) {
SummaryJUnitResultFormatter f = new SummaryJUnitResultFormatter();
f.setWithOutAndErr("withoutanderr".equalsIgnoreCase(summaryValue));
addTimeout(test, f, getDefaultOutput());
}
}

/**
* Adds the actual timeout to the formatter.
* Only used from the logTimeout method.
* @since Ant 1.6
*/
private void addTimeout(JUnitTest test, JUnitResultFormatter formatter,
OutputStream out) {
formatter.setOutput(out);
formatter.startTestSuite(test);
test.setCounts(0, 0, 1);
Test t = new Test() {
public int countTestCases() { return 0; }
public void run(TestResult r) {
throw new AssertionFailedError("Timeout occurred");
}
};
formatter.startTest(t);
formatter.addError(t, new AssertionFailedError("Timeout occurred"));
formatter.endTestSuite(test);
}

/**


Loading…
Cancel
Save