Repository: ant Updated Branches: refs/heads/master ddd729ba9 -> 047e89777
Introduce a "printSummary" attribute on the junitlauncher task to print the test execution summary Project: http://git-wip-us.apache.org/repos/asf/ant/repo Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/047e8977 Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/047e8977 Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/047e8977 Branch: refs/heads/master Commit: 047e897775bd8f53a5cf324bf9f039911d15b081 Parents: ddd729b Author: Jaikiran Pai <[email protected]> Authored: Sun Jun 3 18:52:02 2018 +0530 Committer: Jaikiran Pai <[email protected]> Committed: Sun Jun 3 18:52:02 2018 +0530 ---------------------------------------------------------------------- manual/Tasks/junitlauncher.html | 8 ++++++++ .../optional/junitlauncher/JUnitLauncherTask.java | 10 ++++++++++ 2 files changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ant/blob/047e8977/manual/Tasks/junitlauncher.html ---------------------------------------------------------------------- diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html index 8a32e42..bc360a9 100644 --- a/manual/Tasks/junitlauncher.html +++ b/manual/Tasks/junitlauncher.html @@ -141,6 +141,14 @@ </td> <td>No</td> </tr> + <tr> + <td>printSummary</td> + <td>If the value is set to <code>true</code> then this task, upon completion of the test execution, + prints the summary of the execution to <code>System.out</code>. The summary itself is generated + by the JUnit 5 platform and not by this task. + </td> + <td>No; defaults to <code>false</code></td> + </tr> </table> <h3 id="nested">Nested Elements</h3> http://git-wip-us.apache.org/repos/asf/ant/blob/047e8977/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTask.java ---------------------------------------------------------------------- diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTask.java index dc09a5e..7309e99 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junitlauncher/JUnitLauncherTask.java @@ -21,6 +21,7 @@ import java.io.OutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; import java.io.PrintStream; +import java.io.PrintWriter; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; @@ -57,6 +58,7 @@ public class JUnitLauncherTask extends Task { private Path classPath; private boolean haltOnFailure; private String failureProperty; + private boolean printSummary; private final List<TestDefinition> tests = new ArrayList<>(); private final List<ListenerDefinition> listeners = new ArrayList<>(); @@ -172,6 +174,10 @@ public class JUnitLauncherTask extends Task { this.failureProperty = failureProperty; } + public void setPrintSummary(final boolean printSummary) { + this.printSummary = printSummary; + } + private void preConfigure(final TestDefinition test) { if (test.getHaltOnFailure() == null) { test.setHaltOnFailure(this.haltOnFailure); @@ -267,6 +273,10 @@ public class JUnitLauncherTask extends Task { } private void handleTestExecutionCompletion(final TestDefinition test, final TestExecutionSummary summary) { + if (printSummary) { + // print the summary to System.out + summary.printTo(new PrintWriter(System.out, true)); + } final boolean hasTestFailures = summary.getTestsFailedCount() != 0; try { if (hasTestFailures && test.getFailureProperty() != null) {
