[ https://issues.apache.org/jira/browse/SUREFIRE-1857?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17222541#comment-17222541 ]
Tibor Digana edited comment on SUREFIRE-1857 at 10/28/20, 10:42 PM: -------------------------------------------------------------------- If the message is null we just ignore it, but i think you are right because we forget to transfer the message if the failure happens. This call refused to observe the message, see the [line 129|https://github.com/apache/maven-surefire/blob/master/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java#L129]. I think you can contribute and provide a fix. It looks simple! was (Author: tibor17): If the message is null we just ignore it, but i think you are right because we forget to transfer the message if the error happened. This call refused to observe the message, see the [line 133|https://github.com/apache/maven-surefire/blob/master/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/RunListenerAdapter.java#L133]. I think you can contribute and provide a fix. It looks simple! > JUnit 5 report does not contain assertion failure 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-M4, 3.0.0-M5 > Reporter: Niklas Krieger > Priority: Major > > 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)