You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Niklas Krieger (Jira)" <ji...@apache.org> on 2020/10/27 08:58:00 UTC

[jira] [Created] (SUREFIRE-1857) JUnit 5 report does not contain assertion message

Niklas Krieger created SUREFIRE-1857:
----------------------------------------

             Summary: JUnit 5 report does not contain assertion message
                 Key: SUREFIRE-1857
                 URL: https://issues.apache.org/jira/browse/SUREFIRE-1857
             Project: Maven Surefire
          Issue Type: Bug
          Components: JUnit 5.x support
    Affects Versions: 3.0.0-M5, 3.0.0-M4
            Reporter: Niklas Krieger


Since JUnit 5, if a test fails due to an assertion, the xml report does not contain the assertion message. According to the report specification, the message should be included:
{code:java}
<xs:element name="failure" nillable="true" minOccurs="0" maxOccurs="unbounded">
    <xs:complexType>
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="message" type="xs:string"/>
                <xs:attribute name="type" type="xs:string" use="required"/>
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>
</xs:element>{code}
 

Pom contains:
{code:java}
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>3.0.0-M5</version>
        </plugin>
    </plugins>
</build>
{code}
Test:
{code:java}
package com.example;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

public class MyTest {
    @Test
    public void test() {
        Assertions.assertEquals(1, 2, "two is not one");
    }
}
{code}
Generated report:
{code:java}
<testcase name="test" classname="com.example.MyTest" time="0.018">
    <failure type="org.opentest4j.AssertionFailedError"><![CDATA[org.opentest4j.AssertionFailedError: five is not six ==> expected: <5> but was: <6>
   at TestProject/com.example.MyTest.test(MyTest.java:9)
]]></failure>
</testcase>
{code}
 

Possible reason for this behavior:

In version m3, RunListenerAdapter uses SimpleReportEntry.withException to generate the entry if the test failed due to an assertion

Since Version m4, a constructor of SimpleReportEntry is used, however it gets null as message



--
This message was sent by Atlassian Jira
(v8.3.4#803005)