diff --git a/manual/Tasks/junitlauncher.html b/manual/Tasks/junitlauncher.html index 8a32e42a6..bc360a9a1 100644 --- a/manual/Tasks/junitlauncher.html +++ b/manual/Tasks/junitlauncher.html @@ -141,6 +141,14 @@ No + + printSummary + If the value is set to true then this task, upon completion of the test execution, + prints the summary of the execution to System.out. The summary itself is generated + by the JUnit 5 platform and not by this task. + + No; defaults to false +

Nested Elements

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 dc09a5eea..7309e99d2 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 tests = new ArrayList<>(); private final List 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) {