You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2020/02/03 07:35:42 UTC

[maven-surefire] branch master updated: SUREFIRE-1744 - enable system-out for successful tests as well

This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git


The following commit(s) were added to refs/heads/master by this push:
     new b803256  SUREFIRE-1744 - enable system-out for successful tests as well
b803256 is described below

commit b80325616daa323eb71a04a61d7485a1d303230c
Author: klevis.ramo <kl...@wirecard.com>
AuthorDate: Fri Jan 10 09:19:09 2020 +0100

    SUREFIRE-1744 - enable system-out for successful tests as well
    
    SUREFIRE-1744 - fix failing test
    
    SUREFIRE-1744 - fix style checks
    
    Revert "GitHub CI: removed on: pull_request"
    
    This reverts commit 993214d2ba4bfe7952ecc62af66eaa77a8d381d1.
    
    SUREFIRE-1744 - add integration test checking that output is included in report even when tests is successful
    
    SUREFIRE-1744 - fix style check error
    
    SUREFIRE-1744 - fix typo
---
 .github/workflows/maven.yml                        |  2 +-
 .../surefire/report/StatelessXmlReporter.java      |  2 +-
 .../Surefire1744AlwaysIncludeOutputLogsIT.java     | 42 +++++++++++++++
 .../surefire-1744-alwaysIncludeOutputLogs/pom.xml  | 61 ++++++++++++++++++++++
 .../src/main/resources/log4j.properties            | 24 +++++++++
 .../alwaysIncludeOutputLogs/TestSurefire3.java     | 34 ++++++++++++
 6 files changed, 163 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
index 0d56bb9..5340988 100644
--- a/.github/workflows/maven.yml
+++ b/.github/workflows/maven.yml
@@ -17,7 +17,7 @@
 
 name: GitHub CI
 
-on: [push]
+on: [push, pull_request]
 
 jobs:
   build:
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 1637b24..da1f708 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
@@ -224,8 +224,8 @@ public class StatelessXmlReporter
             {
                 getTestProblems( fw, ppw, methodEntry, trimStackTrace, outputStream,
                         methodEntry.getReportEntryType().getXmlTag(), false );
-                createOutErrElements( fw, ppw, methodEntry, outputStream );
             }
+            createOutErrElements( fw, ppw, methodEntry, outputStream );
             ppw.endElement();
         }
     }
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java
new file mode 100644
index 0000000..5c4cfaf
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1744AlwaysIncludeOutputLogsIT.java
@@ -0,0 +1,42 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.
+ */
+
+import org.apache.maven.surefire.its.fixture.OutputValidator;
+import org.apache.maven.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+
+/**
+ * Test Surefire-224 (XML test reports are not well-formed when failure message contains quotes)
+ *
+ * @author <a href="mailto:dfabulich@apache.org">Dan Fabulich</a>
+ */
+public class Surefire1744AlwaysIncludeOutputLogsIT
+    extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void testAlwaysIncludeOutputLogs()
+    {
+        OutputValidator outputValidator = unpack( "/surefire-1744-alwaysIncludeOutputLogs" ).executeTest();
+
+        outputValidator.verifyTextInLog( "Log output should be included in the report" );
+        outputValidator.verifyTextInLog( "System-out output should be included in the report" );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml
new file mode 100644
index 0000000..5ea0007
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.maven.surefire</groupId>
+        <artifactId>it-parent</artifactId>
+        <version>1.0</version>
+    </parent>
+
+    <groupId>org.apache.maven.plugins.surefire</groupId>
+    <artifactId>surefire1744-alwaysIncludeOutputLogs</artifactId>
+    <version>1.0</version>
+
+    <url>http://maven.apache.org</url>
+
+    <dependencies>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.0</version>
+        </dependency>
+        <dependency>
+            <groupId>log4j</groupId>
+            <artifactId>log4j</artifactId>
+            <version>1.2.16</version>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/src/main/resources/log4j.properties b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/src/main/resources/log4j.properties
new file mode 100644
index 0000000..070ddc9
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/src/main/resources/log4j.properties
@@ -0,0 +1,24 @@
+
+log4j.rootLogger=debug, stdout, xml, R
+
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+
+log4j.appender.xml=org.apache.log4j.FileAppender
+log4j.appender.xml.file=example_xml.log
+log4j.appender.xml.append=false
+log4j.appender.xml.layout=org.apache.log4j.xml.XMLLayout
+
+# Pattern to output the caller's file name and line number.
+log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) - %m%n
+
+log4j.appender.R=org.apache.log4j.RollingFileAppender
+log4j.appender.R.File=example.log
+
+
+log4j.appender.R.MaxFileSize=100KB
+# Keep one backup file
+log4j.appender.R.MaxBackupIndex=1
+
+log4j.appender.R.layout=org.apache.log4j.PatternLayout
+log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n
\ No newline at end of file
diff --git a/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/src/test/java/alwaysIncludeOutputLogs/TestSurefire3.java b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/src/test/java/alwaysIncludeOutputLogs/TestSurefire3.java
new file mode 100644
index 0000000..0f0345b
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1744-alwaysIncludeOutputLogs/src/test/java/alwaysIncludeOutputLogs/TestSurefire3.java
@@ -0,0 +1,34 @@
+package alwaysIncludeOutputLogs;
+
+/*
+ * 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.
+ */
+
+import org.junit.Test;
+import org.apache.log4j.Logger;
+public class TestSurefire3
+{
+    @Test
+    public void successfulTestWithLog()
+    {
+
+        Logger.getLogger( alwaysIncludeOutputLogs.TestSurefire3.class )
+            .info( "Log output should be included in the report" );
+        System.out.println( "System-out output should be included in the report" );
+    }
+}