Skip to content

Commit

Permalink
Process comments...
Browse files Browse the repository at this point in the history
  • Loading branch information
michael-o committed Jun 29, 2024
1 parent e415e12 commit 3dc5ab1
Show file tree
Hide file tree
Showing 17 changed files with 96 additions and 86 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -691,14 +691,12 @@ public abstract class AbstractSurefireMojo extends AbstractMojo implements Suref
private boolean enableAssertions;

/**
* Flag for including/excluding system-out and system-err elements in xml reports.
* <br>
* True by default.
*
* @since 3.0.0
* Flag for including/excluding {@code <system-out />} and {@code <system-err />} elements in XML reports.
* Note that the default value may change to {@code false} is a future version.
* @since 3.3.1
*/
@Parameter(property = "enableOutputElements", defaultValue = "true")
private boolean enableOutputElements;
@Parameter(property = "enableOutErrElements", defaultValue = "true")
private boolean enableOutErrElements;

/**
* The current build session instance.
Expand Down Expand Up @@ -1486,7 +1484,7 @@ private void convertJunitCoreParameters() throws MojoExecutionException {
.setProperty(ProviderParameterNames.PARALLEL_OPTIMIZE_PROP, Boolean.toString(isParallelOptimized()));
getProperties()
.setProperty(
ProviderParameterNames.ENABLE_OUTPUT_ELEMENTS_PROP, Boolean.toString(isEnableOutputElements()));
ProviderParameterNames.ENABLE_OUT_ERR_ELEMENTS_PROP, Boolean.toString(isEnableOutErrElements()));

String message = "parallel='" + usedParallel + '\''
+ ", perCoreThreadCount=" + getPerCoreThreadCount()
Expand All @@ -1496,7 +1494,7 @@ private void convertJunitCoreParameters() throws MojoExecutionException {
+ ", threadCountClasses=" + getThreadCountClasses()
+ ", threadCountMethods=" + getThreadCountMethods()
+ ", parallelOptimized=" + isParallelOptimized()
+ ", enableOutputElements=" + isEnableOutputElements();
+ ", enableOutErrElements=" + isEnableOutErrElements();

logDebugOrCliShowErrors(message);
}
Expand Down Expand Up @@ -1990,7 +1988,7 @@ private StartupReportConfiguration getStartupReportConfiguration(String configCh
getReportSchemaLocation(),
getEncoding(),
isForking,
isEnableOutputElements(),
isEnableOutErrElements(),
xmlReporter,
outReporter,
testsetReporter);
Expand Down Expand Up @@ -2531,7 +2529,7 @@ private String getConfigChecksum() {
checksum.add(getTempDir());
checksum.add(useModulePath());
checksum.add(getEnableProcessChecker());
checksum.add(isEnableOutputElements());
checksum.add(isEnableOutErrElements());
addPluginSpecificChecksumItems(checksum);
return checksum.getSha1();
}
Expand Down Expand Up @@ -3488,13 +3486,13 @@ public void setEnableAssertions(boolean enableAssertions) {
this.enableAssertions = enableAssertions;
}

public boolean isEnableOutputElements() {
return enableOutputElements;
public boolean isEnableOutErrElements() {
return enableOutErrElements;
}

@SuppressWarnings("UnusedDeclaration")
public void setEnableOutputElements(boolean enableOutputElements) {
this.enableOutputElements = enableOutputElements;
public void setEnableOutErrElements(boolean enableOutErrElements) {
this.enableOutErrElements = enableOutErrElements;
}

public MavenSession getSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ private Object createStartupReportConfiguration(@Nonnull StartupReportConfigurat
reporterConfiguration.getXsdSchemaLocation(),
reporterConfiguration.getEncoding().name(),
reporterConfiguration.isForking(),
reporterConfiguration.isEnableOutputElements(),
reporterConfiguration.isEnableOutErrElements(),
reporterConfiguration.getXmlReporter().clone(surefireClassLoader),
reporterConfiguration.getConsoleOutputReporter().clone(surefireClassLoader),
reporterConfiguration.getTestsetReporter().clone(surefireClassLoader)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public final class StartupReportConfiguration {

private final boolean isForking;

private final boolean enableOutputElements;
private final boolean enableOutErrElements;

private final SurefireStatelessReporter xmlReporter;

Expand All @@ -110,7 +110,7 @@ public StartupReportConfiguration(
String xsdSchemaLocation,
String encoding,
boolean isForking,
boolean enableOutputElements,
boolean enableOutErrElements,
SurefireStatelessReporter xmlReporter,
SurefireConsoleOutputReporter consoleOutputReporter,
SurefireStatelessTestsetInfoReporter testsetReporter) {
Expand All @@ -130,7 +130,7 @@ public StartupReportConfiguration(
String charset = trimToNull(encoding);
this.encoding = charset == null ? UTF_8 : Charset.forName(charset);
this.isForking = isForking;
this.enableOutputElements = enableOutputElements;
this.enableOutErrElements = enableOutErrElements;
this.xmlReporter = xmlReporter;
this.consoleOutputReporter = consoleOutputReporter;
this.testsetReporter = testsetReporter;
Expand Down Expand Up @@ -181,7 +181,7 @@ public StatelessReportEventListener<WrappedReportEntry, TestSetStats> instantiat
trimStackTrace,
rerunFailingTestsCount,
xsdSchemaLocation,
enableOutputElements,
enableOutErrElements,
testClassMethodRunHistory);

return xmlReporter.isDisable() ? null : xmlReporter.createListener(xmlReporterConfig);
Expand Down Expand Up @@ -244,8 +244,8 @@ public boolean isForking() {
return isForking;
}

public boolean isEnableOutputElements() {
return enableOutputElements;
public boolean isEnableOutErrElements() {
return enableOutErrElements;
}

private File resolveReportsDirectory(Integer forkNumber) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ public DefaultStatelessReportMojoConfiguration(
boolean trimStackTrace,
int rerunFailingTestsCount,
String xsdSchemaLocation,
boolean enableOutputElements,
boolean enableOutErrElements,
Map<String, Deque<WrappedReportEntry>> testClassMethodRunHistory) {
super(
reportsDirectory,
reportNameSuffix,
trimStackTrace,
rerunFailingTestsCount,
xsdSchemaLocation,
enableOutputElements);
enableOutErrElements);
this.testClassMethodRunHistory = testClassMethodRunHistory;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public StatelessReportEventListener<WrappedReportEntry, TestSetStats> createList
configuration.getRerunFailingTestsCount(),
configuration.getTestClassMethodRunHistory(),
configuration.getXsdSchemaLocation(),
configuration.isEnableOutputElements(),
configuration.isEnableOutErrElements(),
getVersion(),
false,
false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public StatelessReportEventListener<WrappedReportEntry, TestSetStats> createList
configuration.getRerunFailingTestsCount(),
configuration.getTestClassMethodRunHistory(),
configuration.getXsdSchemaLocation(),
configuration.isEnableOutputElements(),
configuration.isEnableOutErrElements(),
getVersion(),
getUsePhrasedFileName(),
getUsePhrasedTestSuiteClassName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ public class ProviderParameterNames {

public static final String PARALLEL_OPTIMIZE_PROP = "paralleloptimization";

public static final String ENABLE_OUTPUT_ELEMENTS_PROP = "enableoutputelements";
public static final String ENABLE_OUT_ERR_ELEMENTS_PROP = "enableouterrelements";
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,21 +36,21 @@ public class StatelessReportMojoConfiguration {

private final String xsdSchemaLocation;

private final boolean enableOutputElements;
private final boolean enableOutErrElements;

public StatelessReportMojoConfiguration(
File reportsDirectory,
String reportNameSuffix,
boolean trimStackTrace,
int rerunFailingTestsCount,
String xsdSchemaLocation,
boolean enableOutputElements) {
boolean enableOutErrElements) {
this.reportsDirectory = reportsDirectory;
this.reportNameSuffix = reportNameSuffix;
this.trimStackTrace = trimStackTrace;
this.rerunFailingTestsCount = rerunFailingTestsCount;
this.xsdSchemaLocation = xsdSchemaLocation;
this.enableOutputElements = enableOutputElements;
this.enableOutErrElements = enableOutErrElements;
}

public File getReportsDirectory() {
Expand All @@ -73,7 +73,7 @@ public String getXsdSchemaLocation() {
return xsdSchemaLocation;
}

public boolean isEnableOutputElements() {
return enableOutputElements;
public boolean isEnableOutErrElements() {
return enableOutErrElements;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,25 @@
*
* @author NissMoony
*/
public class Surefire1934OutElementsIT extends SurefireJUnit4IntegrationTestCase {
public class Surefire1934OutErrElementsIT extends SurefireJUnit4IntegrationTestCase {

@Test
public void testOutElementsDisabled() {
public void testOutErrElementsDisabled() {
final OutputValidator outputValidator =
unpack("/surefire-1934-disable-out-elements").executeTest();
unpack("/surefire-1934-disable-out-err-elements").executeTest();
final TestFile reportFile =
outputValidator.getSurefireReportsXmlFile("TEST-disableOutElements.TestOutElements.xml");
outputValidator.getSurefireReportsXmlFile("TEST-disableOutErrElements.TestOutErrElements.xml");

reportFile.assertNotContainsText("<system-out>");
reportFile.assertNotContainsText("<system-err>");
}

@Test
public void testOutElementsEnabled() {
public void testOutErrElementsEnabled() {
final OutputValidator outputValidator =
unpack("/surefire-1934-enable-out-elements").executeTest();
unpack("/surefire-1934-enable-out-err-elements").executeTest();
final TestFile reportFile =
outputValidator.getSurefireReportsXmlFile("TEST-enableOutElements.TestOutElements.xml");
outputValidator.getSurefireReportsXmlFile("TEST-enableOutErrElements.TestOutErrElements.xml");

reportFile.assertContainsText("<system-out>");
reportFile.assertContainsText("<system-err>");
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</parent>

<groupId>org.apache.maven.plugins.surefire</groupId>
<artifactId>surefire-1934-disable-out-elements</artifactId>
<artifactId>surefire-1934-disable-out-err-elements</artifactId>
<version>1.0</version>
<url>http://maven.apache.org</url>

Expand All @@ -41,9 +41,15 @@
<version>4.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
<scope>runtime</scope>
</dependency>
</dependencies>

Expand All @@ -54,7 +60,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${surefire.version}</version>
<configuration>
<enableOutputElements>false</enableOutputElements>
<enableOutErrElements>false</enableOutErrElements>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package disableOutElements;

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.");
}

}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
</parent>

<groupId>org.apache.maven.plugins.surefire</groupId>
<artifactId>surefire-1934-disable-out-elements</artifactId>
<artifactId>surefire-1934-disable-out-err-elements</artifactId>
<version>1.0</version>
<url>http://maven.apache.org</url>

Expand All @@ -41,9 +41,15 @@
<version>4.0</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.16</version>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.36</version>
<scope>runtime</scope>
</dependency>
</dependencies>

Expand All @@ -55,7 +61,7 @@
<version>${surefire.version}</version>
<configuration>
<!-- Default value, but setting it explicitly for test -->
<enableOutputElements>true</enableOutputElements>
<enableOutErrElements>true</enableOutErrElements>
</configuration>
</plugin>
</plugins>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package enableOutElements;

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.");
}

}
Loading

0 comments on commit 3dc5ab1

Please sign in to comment.