diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 664121d04b..8552fcdcc8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -690,6 +690,16 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref
@Parameter(property = "enableAssertions", defaultValue = "true")
private boolean enableAssertions;
+ /**
+ * Flag for including/excluding {@code } and {@code } elements for
+ * successfully passed tests in XML reports.
+ * Note that the default value may change to {@code false} is a future version.
+ *
+ * @since 3.3.1
+ */
+ @Parameter(property = "enableOutErrElements", defaultValue = "true")
+ private boolean enableOutErrElements;
+
/**
* The current build session instance.
*/
@@ -1474,6 +1484,10 @@ private void convertJunitCoreParameters() throws MojoExecutionException {
Double.toString(getParallelTestsTimeoutForcedInSeconds()));
getProperties()
.setProperty(ProviderParameterNames.PARALLEL_OPTIMIZE_PROP, Boolean.toString(isParallelOptimized()));
+ getProperties()
+ .setProperty(
+ ProviderParameterNames.ENABLE_OUT_ERR_ELEMENTS_PROP,
+ Boolean.toString(isEnableOutErrElements()));
String message = "parallel='" + usedParallel + '\''
+ ", perCoreThreadCount=" + getPerCoreThreadCount()
@@ -1482,7 +1496,8 @@ private void convertJunitCoreParameters() throws MojoExecutionException {
+ ", threadCountSuites=" + getThreadCountSuites()
+ ", threadCountClasses=" + getThreadCountClasses()
+ ", threadCountMethods=" + getThreadCountMethods()
- + ", parallelOptimized=" + isParallelOptimized();
+ + ", parallelOptimized=" + isParallelOptimized()
+ + ", enableOutErrElements=" + isEnableOutErrElements();
logDebugOrCliShowErrors(message);
}
@@ -1976,6 +1991,7 @@ private StartupReportConfiguration getStartupReportConfiguration(String configCh
getReportSchemaLocation(),
getEncoding(),
isForking,
+ isEnableOutErrElements(),
xmlReporter,
outReporter,
testsetReporter);
@@ -2516,6 +2532,7 @@ private String getConfigChecksum() {
checksum.add(getTempDir());
checksum.add(useModulePath());
checksum.add(getEnableProcessChecker());
+ checksum.add(isEnableOutErrElements());
addPluginSpecificChecksumItems(checksum);
return checksum.getSha1();
}
@@ -3472,6 +3489,15 @@ public void setEnableAssertions(boolean enableAssertions) {
this.enableAssertions = enableAssertions;
}
+ public boolean isEnableOutErrElements() {
+ return enableOutErrElements;
+ }
+
+ @SuppressWarnings("UnusedDeclaration")
+ public void setEnableOutErrElements(boolean enableOutErrElements) {
+ this.enableOutErrElements = enableOutErrElements;
+ }
+
public MavenSession getSession() {
return session;
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
index 0d76ee8ce9..4aaa34c631 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/CommonReflector.java
@@ -86,6 +86,7 @@ private Object createStartupReportConfiguration(@Nonnull StartupReportConfigurat
String.class,
String.class,
boolean.class,
+ boolean.class,
statelessTestsetReporter,
consoleOutputReporter,
statelessTestsetInfoReporter);
@@ -103,6 +104,7 @@ private Object createStartupReportConfiguration(@Nonnull StartupReportConfigurat
reporterConfiguration.getXsdSchemaLocation(),
reporterConfiguration.getEncoding().name(),
reporterConfiguration.isForking(),
+ reporterConfiguration.isEnableOutErrElements(),
reporterConfiguration.getXmlReporter().clone(surefireClassLoader),
reporterConfiguration.getConsoleOutputReporter().clone(surefireClassLoader),
reporterConfiguration.getTestsetReporter().clone(surefireClassLoader)
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
index d42e22cdac..b4994869ed 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/StartupReportConfiguration.java
@@ -85,6 +85,8 @@ public final class StartupReportConfiguration {
private final boolean isForking;
+ private final boolean enableOutErrElements;
+
private final SurefireStatelessReporter xmlReporter;
private final SurefireConsoleOutputReporter consoleOutputReporter;
@@ -108,6 +110,7 @@ public StartupReportConfiguration(
String xsdSchemaLocation,
String encoding,
boolean isForking,
+ boolean enableOutErrElements,
SurefireStatelessReporter xmlReporter,
SurefireConsoleOutputReporter consoleOutputReporter,
SurefireStatelessTestsetInfoReporter testsetReporter) {
@@ -127,6 +130,7 @@ public StartupReportConfiguration(
String charset = trimToNull(encoding);
this.encoding = charset == null ? UTF_8 : Charset.forName(charset);
this.isForking = isForking;
+ this.enableOutErrElements = enableOutErrElements;
this.xmlReporter = xmlReporter;
this.consoleOutputReporter = consoleOutputReporter;
this.testsetReporter = testsetReporter;
@@ -177,6 +181,7 @@ public StatelessReportEventListener instantiat
trimStackTrace,
rerunFailingTestsCount,
xsdSchemaLocation,
+ enableOutErrElements,
testClassMethodRunHistory);
return xmlReporter.isDisable() ? null : xmlReporter.createListener(xmlReporterConfig);
@@ -239,6 +244,10 @@ public boolean isForking() {
return isForking;
}
+ public boolean isEnableOutErrElements() {
+ return enableOutErrElements;
+ }
+
private File resolveReportsDirectory(Integer forkNumber) {
return forkNumber == null ? reportsDirectory : replaceForkThreadsInPath(reportsDirectory, forkNumber);
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReportMojoConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReportMojoConfiguration.java
index f134e24a21..57cae2ad9d 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReportMojoConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/DefaultStatelessReportMojoConfiguration.java
@@ -43,8 +43,15 @@ public DefaultStatelessReportMojoConfiguration(
boolean trimStackTrace,
int rerunFailingTestsCount,
String xsdSchemaLocation,
+ boolean enableOutErrElements,
Map> testClassMethodRunHistory) {
- super(reportsDirectory, reportNameSuffix, trimStackTrace, rerunFailingTestsCount, xsdSchemaLocation);
+ super(
+ reportsDirectory,
+ reportNameSuffix,
+ trimStackTrace,
+ rerunFailingTestsCount,
+ xsdSchemaLocation,
+ enableOutErrElements);
this.testClassMethodRunHistory = testClassMethodRunHistory;
}
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireStatelessReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireStatelessReporter.java
index ebd7d0051f..5083418bc5 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireStatelessReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/SurefireStatelessReporter.java
@@ -68,7 +68,8 @@ public StatelessReportEventListener createList
false,
false,
false,
- false);
+ false,
+ configuration.isEnableOutErrElements());
}
@Override
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5Xml30StatelessReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5Xml30StatelessReporter.java
index 689a4caed8..a72f223864 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5Xml30StatelessReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/extensions/junit5/JUnit5Xml30StatelessReporter.java
@@ -107,7 +107,8 @@ public StatelessReportEventListener createList
getUsePhrasedFileName(),
getUsePhrasedTestSuiteClassName(),
getUsePhrasedTestCaseClassName(),
- getUsePhrasedTestCaseMethodName());
+ getUsePhrasedTestCaseMethodName(),
+ configuration.isEnableOutErrElements());
}
@Override
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
index 73ec5a282e..dc24f66a32 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/NullStatelessXmlReporter.java
@@ -29,7 +29,7 @@ class NullStatelessXmlReporter extends StatelessXmlReporter {
static final NullStatelessXmlReporter INSTANCE = new NullStatelessXmlReporter();
private NullStatelessXmlReporter() {
- super(null, null, false, 0, null, null, null, false, false, false, false);
+ super(null, null, false, 0, null, null, null, false, false, false, false, true);
}
@Override
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
index f5f2916c5e..f8c14bdaa4 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporter.java
@@ -116,6 +116,8 @@ public class StatelessXmlReporter implements StatelessReportEventListener> testClassMethodRunHistory = new HashMap<>();
DefaultStatelessReportMojoConfiguration config = new DefaultStatelessReportMojoConfiguration(
- reportsDirectory, reportNameSuffix, true, 5, schema, testClassMethodRunHistory);
+ reportsDirectory, reportNameSuffix, true, 5, schema, true, testClassMethodRunHistory);
SurefireStatelessReporter extension = new SurefireStatelessReporter();
assertThat(extension.getVersion()).isEqualTo("3.0.1");
@@ -141,7 +141,7 @@ public void shouldCreateJUnit5ConsoleListener() {
String schema = "https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd";
Map> testClassMethodRunHistory = new HashMap<>();
DefaultStatelessReportMojoConfiguration config = new DefaultStatelessReportMojoConfiguration(
- reportsDirectory, reportNameSuffix, true, 5, schema, testClassMethodRunHistory);
+ reportsDirectory, reportNameSuffix, true, 5, schema, true, testClassMethodRunHistory);
JUnit5Xml30StatelessReporter extension = new JUnit5Xml30StatelessReporter();
assertThat(extension.getVersion()).isEqualTo("3.0.1");
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
index e767c30f16..081248f47c 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/DefaultReporterFactoryTest.java
@@ -85,6 +85,7 @@ public void testMergeTestHistoryResult() throws Exception {
null,
null,
false,
+ true,
new SurefireStatelessReporter(),
new SurefireConsoleOutputReporter(),
new SurefireStatelessTestsetInfoReporter());
@@ -288,6 +289,7 @@ public void testLogger() {
null,
null,
false,
+ true,
new SurefireStatelessReporter(),
new SurefireConsoleOutputReporter(),
new SurefireStatelessTestsetInfoReporter());
@@ -352,6 +354,7 @@ public void testCreateReporterWithZeroStatistics() {
null,
null,
false,
+ true,
new SurefireStatelessReporter(),
new SurefireConsoleOutputReporter(),
new SurefireStatelessTestsetInfoReporter());
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
index f46bb20016..70e87e0e16 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/report/StatelessXmlReporterTest.java
@@ -109,7 +109,8 @@ public void testFileNameWithoutSuffix() {
false,
false,
false,
- false);
+ false,
+ true);
reporter.cleanTestHistoryMap();
ReportEntry reportEntry = new SimpleReportEntry(
@@ -169,7 +170,8 @@ public void testAllFieldsSerialized() throws IOException {
false,
false,
false,
- false);
+ false,
+ true);
reporter.testSetCompleted(testSetReportEntry, stats);
FileInputStream fileInputStream = new FileInputStream(expectedReportFile);
@@ -271,7 +273,8 @@ public void testOutputRerunFlakyFailure() throws IOException {
false,
false,
false,
- false);
+ false,
+ true);
reporter.testSetCompleted(testSetReportEntry, stats);
reporter.testSetCompleted(testSetReportEntry, rerunStats);
@@ -370,7 +373,7 @@ public void testOutputRerunFlakyAssumption() throws IOException {
rerunStats.testSucceeded(testTwoSecondError);
StatelessXmlReporter reporter = new StatelessXmlReporter(
- reportDir, null, false, 1, new HashMap<>(), XSD, "3.0.1", false, false, false, false);
+ reportDir, null, false, 1, new HashMap<>(), XSD, "3.0.1", false, false, false, false, true);
WrappedReportEntry testSetReportEntry = new WrappedReportEntry(
new SimpleReportEntry(
@@ -534,7 +537,7 @@ public void testReporterHandlesATestWithoutMessageAndWithEmptyStackTrace() {
null);
StatelessXmlReporter reporter = new StatelessXmlReporter(
- reportDir, null, false, 1, new HashMap<>(), XSD, "3.0.1", false, false, false, false);
+ reportDir, null, false, 1, new HashMap<>(), XSD, "3.0.1", false, false, false, false, true);
reporter.testSetCompleted(testReport, stats);
}
diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java b/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java
index d59d3de3e8..95da2d3bee 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/api/booter/ProviderParameterNames.java
@@ -45,4 +45,6 @@ public class ProviderParameterNames {
public static final String PARALLEL_TIMEOUTFORCED_PROP = "paralleltimeoutforced";
public static final String PARALLEL_OPTIMIZE_PROP = "paralleloptimization";
+
+ public static final String ENABLE_OUT_ERR_ELEMENTS_PROP = "enableouterrelements";
}
diff --git a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportMojoConfiguration.java b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportMojoConfiguration.java
index f0424207a7..ec3716deb9 100644
--- a/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportMojoConfiguration.java
+++ b/surefire-extensions-api/src/main/java/org/apache/maven/surefire/extensions/StatelessReportMojoConfiguration.java
@@ -36,17 +36,21 @@ public class StatelessReportMojoConfiguration {
private final String xsdSchemaLocation;
+ private final boolean enableOutErrElements;
+
public StatelessReportMojoConfiguration(
File reportsDirectory,
String reportNameSuffix,
boolean trimStackTrace,
int rerunFailingTestsCount,
- String xsdSchemaLocation) {
+ String xsdSchemaLocation,
+ boolean enableOutErrElements) {
this.reportsDirectory = reportsDirectory;
this.reportNameSuffix = reportNameSuffix;
this.trimStackTrace = trimStackTrace;
this.rerunFailingTestsCount = rerunFailingTestsCount;
this.xsdSchemaLocation = xsdSchemaLocation;
+ this.enableOutErrElements = enableOutErrElements;
}
public File getReportsDirectory() {
@@ -68,4 +72,8 @@ public int getRerunFailingTestsCount() {
public String getXsdSchemaLocation() {
return xsdSchemaLocation;
}
+
+ public boolean isEnableOutErrElements() {
+ return enableOutErrElements;
+ }
}
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java
new file mode 100644
index 0000000000..8f46ce779b
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1934OutErrElementsIT.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.surefire.its.jiras;
+
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.apache.maven.surefire.its.fixture.TestFile;
+import org.junit.Test;
+
+/**
+ * Test for SUREFURE-1934. Enabling and disabling system-out and system-err elements in plugin configuration.
+ *
+ * @author NissMoony
+ */
+public class Surefire1934OutErrElementsIT extends SurefireJUnit4IntegrationTestCase {
+
+ @Test
+ public void testOutErrElementsDisabled() {
+ final OutputValidator outputValidator = unpack("/surefire-1934-disable-out-err-elements")
+ .maven()
+ .withFailure()
+ .executeTest();
+ final TestFile reportFile =
+ outputValidator.getSurefireReportsXmlFile("TEST-disableOutErrElements.TestOutErrElements.xml");
+
+ reportFile.assertNotContainsText("");
+ reportFile.assertContainsText("");
+ }
+}
diff --git a/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml b/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml
new file mode 100644
index 0000000000..4deef9036e
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/pom.xml
@@ -0,0 +1,69 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.surefire
+ it-parent
+ 1.0
+ ../pom.xml
+
+
+ org.apache.maven.plugins.surefire
+ surefire-1934-disable-out-err-elements
+ 1.0
+ http://maven.apache.org
+
+
+
+ junit
+ junit
+ 4.0
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.36
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.36
+ runtime
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+ false
+
+
+
+
+
+
diff --git a/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/src/test/java/disableOutErrElements/TestOutErrElements.java b/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/src/test/java/disableOutErrElements/TestOutErrElements.java
new file mode 100644
index 0000000000..95f4cae46a
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1934-disable-out-err-elements/src/test/java/disableOutErrElements/TestOutErrElements.java
@@ -0,0 +1,23 @@
+package disableOutErrElements;
+
+import org.junit.Test;
+import org.slf4j.LoggerFactory;
+
+public class TestOutErrElements {
+
+ @Test
+ public void successfulTestWithLogs() {
+ LoggerFactory.getLogger(TestOutErrElements.class).info("Log output not expected in test report.");
+ System.out.println("System-out output not expected in the report.");
+ System.err.println("System-err output not expected in the report.");
+ }
+
+ @Test
+ public void failedTestWithLogs() throws Exception {
+ LoggerFactory.getLogger(TestOutErrElements.class).info("Log output expected in test report.");
+ System.out.println("System-out output expected in the report.");
+ System.err.println("System-err output expected in the report.");
+ throw new Exception("Expected to fail");
+ }
+
+}
diff --git a/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml b/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml
new file mode 100644
index 0000000000..7b0723b682
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/pom.xml
@@ -0,0 +1,70 @@
+
+
+
+
+ 4.0.0
+
+
+ org.apache.maven.surefire
+ it-parent
+ 1.0
+ ../pom.xml
+
+
+ org.apache.maven.plugins.surefire
+ surefire-1934-disable-out-err-elements
+ 1.0
+ http://maven.apache.org
+
+
+
+ junit
+ junit
+ 4.0
+
+
+ org.slf4j
+ slf4j-api
+ 1.7.36
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.36
+ runtime
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ ${surefire.version}
+
+
+ true
+
+
+
+
+
+
diff --git a/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/src/test/java/enableOutErrElements/TestOutErrElements.java b/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/src/test/java/enableOutErrElements/TestOutErrElements.java
new file mode 100644
index 0000000000..37f106cc83
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1934-enable-out-err-elements/src/test/java/enableOutErrElements/TestOutErrElements.java
@@ -0,0 +1,15 @@
+package enableOutErrElements;
+
+import org.junit.Test;
+import org.slf4j.LoggerFactory;
+
+public class TestOutErrElements {
+
+ @Test
+ public void successfulTestWithLogs() {
+ LoggerFactory.getLogger(TestOutErrElements.class).info("Log output expected in test report.");
+ System.out.println("System-out output expected in the report.");
+ System.err.println("System-err output expected in the report.");
+ }
+
+}
diff --git a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
index 600baf476d..3e9beca45d 100644
--- a/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
+++ b/surefire-providers/surefire-junit47/src/main/java/org/apache/maven/surefire/junitcore/JUnitCoreParameters.java
@@ -48,6 +48,8 @@ public final class JUnitCoreParameters {
public static final String PARALLEL_OPTIMIZE_KEY = ProviderParameterNames.PARALLEL_OPTIMIZE_PROP;
+ public static final String ENABLE_OUT_ERR_ELEMENTS_KEY = ProviderParameterNames.ENABLE_OUT_ERR_ELEMENTS_PROP;
+
private final String parallel;
private final boolean perCoreThreadCount;
@@ -68,6 +70,8 @@ public final class JUnitCoreParameters {
private final boolean parallelOptimization;
+ private final boolean enableOutErrElements;
+
public JUnitCoreParameters(Map properties) {
parallel = property(properties, PARALLEL_KEY, "none").toLowerCase();
perCoreThreadCount = property(properties, PERCORETHREADCOUNT_KEY, true);
@@ -79,6 +83,7 @@ public JUnitCoreParameters(Map properties) {
parallelTestsTimeoutInSeconds = Math.max(property(properties, PARALLEL_TIMEOUT_KEY, 0d), 0);
parallelTestsTimeoutForcedInSeconds = Math.max(property(properties, PARALLEL_TIMEOUTFORCED_KEY, 0d), 0);
parallelOptimization = property(properties, PARALLEL_OPTIMIZE_KEY, true);
+ enableOutErrElements = property(properties, ENABLE_OUT_ERR_ELEMENTS_KEY, true);
}
private static Collection lowerCase(String... elements) {
@@ -164,13 +169,18 @@ public boolean isParallelOptimization() {
return parallelOptimization;
}
+ public boolean isEnableOutErrElements() {
+ return enableOutErrElements;
+ }
+
@Override
public String toString() {
return "parallel='" + parallel + '\'' + ", perCoreThreadCount=" + perCoreThreadCount + ", threadCount="
+ threadCount + ", useUnlimitedThreads=" + useUnlimitedThreads + ", threadCountSuites="
+ threadCountSuites
+ ", threadCountClasses=" + threadCountClasses + ", threadCountMethods=" + threadCountMethods
- + ", parallelOptimization=" + parallelOptimization;
+ + ", parallelOptimization=" + parallelOptimization
+ + ", enableOutErrElements=" + enableOutErrElements;
}
private static boolean property(Map properties, String key, boolean fallback) {
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
index 8dd9f55da5..c635ca0d50 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreParametersTest.java
@@ -45,6 +45,7 @@ public void defaultParameters() {
assertThat(newTestSetDefault().getParallelTestsTimeoutInSeconds(), is(0d));
assertThat(newTestSetDefault().getParallelTestsTimeoutForcedInSeconds(), is(0d));
assertTrue(newTestSetDefault().isParallelOptimization());
+ assertTrue(newTestSetDefault().isEnableOutErrElements());
}
@Test
diff --git a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
index ef9c00c707..279a5c4051 100644
--- a/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
+++ b/surefire-providers/surefire-junit47/src/test/java/org/apache/maven/surefire/junitcore/JUnitCoreTester.java
@@ -109,6 +109,7 @@ private static StartupReportConfiguration defaultStartupReportConfiguration() {
null,
null,
false,
+ true,
new SurefireStatelessReporter(),
new SurefireConsoleOutputReporter(),
new SurefireStatelessTestsetInfoReporter());