You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Andreas Pabst (Jira)" <ji...@apache.org> on 2022/10/21 16:12:00 UTC
[jira] [Commented] (SUREFIRE-2120) Surefire report is not produced with test name when using JUnit5 and Specs2
[ https://issues.apache.org/jira/browse/SUREFIRE-2120?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17622349#comment-17622349 ]
Andreas Pabst commented on SUREFIRE-2120:
-----------------------------------------
I had a look at this issue since I was just working on a somewhat related issue with the XML reporting (SUREFIRE-2117).
I don't think this can be fixed in Surefire. Rather the problem appears to be located in the interaction between Specs2 and JUnit 5.
Specs2 provides the following JUnit 4 Description to JUnit 5 for the test: "Single test(samples.MySpecTest)"
The JUnit 5 Vintage Engine tries to identify the TestSource based on that Description. In order to do so, JUnit 5 looks for a method named "Single Test", but there is none, so computeTestSource returns a ClassSource instead of a MethodSource.
See https://github.com/junit-team/junit5/blob/main/junit-vintage-engine/src/main/java/org/junit/vintage/engine/descriptor/TestSourceProvider.java
On a side note, if the pull request https://github.com/apache/maven-surefire/pull/568 with the fix for SUREFIRE-2117 were to be merged, the report entry would look like this:
{noformat}
<testcase name="" classname="MySpecTest Single test" time="0.001"/>
{noformat}
At least the class name would not be missing completely then.
> Surefire report is not produced with test name when using JUnit5 and Specs2
> ---------------------------------------------------------------------------
>
> Key: SUREFIRE-2120
> URL: https://issues.apache.org/jira/browse/SUREFIRE-2120
> Project: Maven Surefire
> Issue Type: Bug
> Affects Versions: 3.0.0-M7
> Reporter: Anatoly
> Priority: Major
> Labels: junit5, reporting, scala, specs2, surefire, teamcity
>
> Hi,
> When running tests from terminal via 'mvn clean test' command, the generated surefire report in 'target/surefire-reports/' does not have a tests name. i.e:
> {code:java}
> <testcase name="" classname="samples.MySpecTest" time="0"/>{code}
> This messes up our TC reporting.
>
> h2. Steps to reproduce
> # Clone my example: [Junit5Specs2SurefireTestName|https://github.com/anatolyra/Junit5Specs2SurefireTestName]
> # Run 'mvn clean test'
> # Open surefire report
> When adding this config:
> {code:java}
> <configuration>
> <statelessTestsetReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5Xml30StatelessReporter">
> <disable>false</disable>
> <version>3.0</version>
> <usePhrasedFileName>false</usePhrasedFileName>
> <usePhrasedTestSuiteClassName>true</usePhrasedTestSuiteClassName>
> <usePhrasedTestCaseClassName>true</usePhrasedTestCaseClassName>
> <usePhrasedTestCaseMethodName>true</usePhrasedTestCaseMethodName>
> </statelessTestsetReporter>
> <consoleOutputReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5ConsoleOutputReporter">
> <disable>false</disable>
> <encoding>UTF-8</encoding>
> <usePhrasedFileName>false</usePhrasedFileName>
> </consoleOutputReporter>
> <statelessTestsetInfoReporter implementation="org.apache.maven.plugin.surefire.extensions.junit5.JUnit5StatelessTestsetInfoReporter">
> <disable>false</disable>
> <usePhrasedFileName>false</usePhrasedFileName>
> <usePhrasedClassNameInRunning>true</usePhrasedClassNameInRunning>
> <usePhrasedClassNameInTestCaseSummary>true</usePhrasedClassNameInTestCaseSummary>
> </statelessTestsetInfoReporter>
> </configuration>{code}
> I get this console output:
> {code:java}
> [INFO] -------------------------------------------------------
> [INFO] T E S T S
> [INFO] -------------------------------------------------------
> [INFO] Running null
> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.075 s - in null
> [INFO]
> [INFO] Results:
> [INFO]
> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
> [INFO]
> [INFO] ----------------[INFO] --------------------------------
> [INFO] T E S T S
> [INFO] -------------------------------------------------------
> [INFO] Running null
> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.075 s - in null
> [INFO]
> [INFO] Results:
> [INFO]
> [INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
> [INFO]
> [INFO] -------------------------------------------------------{code}
> Notice the 'null' instead of the class name.
> And this output in the report:
> {code:java}
> <testcase name="" classname="Single test" time="0.001"/>{code}
> The test name is in classname but again, nothing in the name attribute.
> h2. Context
> * maven-surefire-plugin version 3.0.0-M7
> * scala-maven-plugin both version 4.4.0 and 4.7.2
> * specs2-junit_2.13 version 4.12.1-junit-5 (uses junit-vintage-engine version 5.3.1, also tried with 5.9.0)
> * Scala version 2.13.8
> * Build Tool/IDE: Maven
--
This message was sent by Atlassian Jira
(v8.20.10#820010)