artemmukhin commented on issue #2692:
URL:
https://github.com/apache/maven-surefire/issues/2692#issuecomment-7101322650
Proposal: keep `name` as it is, and add the JUnit display name in a new
optional attribute of `<testcase>`.
By default the XML report has only the legacy reporting name of a JUnit 5
test. With Surefire 3.6.0 and JUnit 6.0.3:
| Test | `name` by default | `name` with `usePhrasedTestCaseMethodName` |
|---|---|---|
| `@ParameterizedTest @ValueSource(strings = {"alpha", "beta"})` |
`words(String)[1]` | `words(String)[1] "alpha"` |
| `@ParameterizedTest(name = "{0} plus {1}")` | `sums(int, int)[1]` |
`sums(int, int) "1" plus "2"` |
| `@Test @DisplayName("a plain test")` | `plain` | `a plain test` |
The phrased option shows the display names, but it replaces `name`. Tools
then lose the method name: for `a plain test` the report no longer says which
method ran, so a tool cannot navigate to it or rerun it with
`-Dtest=Class#method`.
Suggestion:
```xml
<testcase name="words(String)[1]" displayName="[1] "alpha""
classname="demo.ParamTest" time="0.001"/>
<testcase name="plain" displayName="a plain test" classname="demo.ParamTest"
time="0.001"/>
```
- `name` and `classname` do not change, so CI history and old readers keep
working. A reader that does not know `displayName` ignores it.
- A reader that knows it (an IDE, the HTML report) can show what JUnit
shows, with no POM change.
- The value is `TestIdentifier.getDisplayName()`; `<testsuite>` could get
the display name of the class in the same way.
This is the second option that was named in SUREFIRE-1546 ("add two more XML
attributes"). Questions:
1. Would you accept the attribute by default, or only behind the existing
reporter configuration?
2. Does it need a new version of `surefire-test-report.xsd`?
Context: IntelliJ IDEA builds the test tree of a delegated Maven test run
from these reports (https://youtrack.jetbrains.com/issue/IDEA-396297).
If the direction is OK, I can send a pull request with an integration test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]