Skip to content

Dynamic testcase name in xml report is not the same as display-name #4312

@gtach2o

Description

@gtach2o

Hello,

I'm using DynamicTest with @TestFactory all works as expected except xml report generated during execution with console launcher.
The test name set during execution is not propagated to name attribute of testcase node in xml report.

...
String testName = "Test " + index + " - " + page.page();
return DynamicTest.dynamicTest(testName, () -> {
  assertAll(
   () -> assertTrue(test(), page.page())
      );
});
<testcase name="dynamicTests()[17]" classname="foo.bar.ClassName" time="0.001">
        <system-out><![CDATA[
unique-id: [engine:junit-jupiter]/[class:foo.bar.ClassName]/[test-factory:dynamicTests()]/[dynamic-test:#17]
display-name: Test 17 - page.asp
]]></system-out>
    </testcase>

as you can see display-name is correct in CDATA, but attribute is not updated with display name name="dynamicTests()[17]"

expected

<testcase name="Test 17 - page.asp" classname="foo.bar.ClassName" time="0.001">
        <system-out><![CDATA[
unique-id: [engine:junit-jupiter]/[class:foo.bar.ClassName]/[test-factory:dynamicTests()]/[dynamic-test:#17]
display-name: Test 17 - page.asp
]]></system-out>
    </testcase>

I was trying to use TestReporter.publishEntry
Stream<DynamicTest> dynamicTests(TestReporter testReporter)
It didn't work out either.

Context

  • Used versions junit-platform-console-standalone-1.11.4.jar
  • JRE 23

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions