Skip to content

Add support for custom properties in generated junit reports #153

Closed

Description

@timo-reymann

Is your feature request related to a problem? Please describe.
Currently, the JUnit logger only allows logging the default fields.

JUnit supports adding custom properties for test cases, so e.g., the corresponding XML looks like this:

<testsuites tests="1" failures="2" skipped="3" errors="4" time="5.6">
	<testsuite name="MyTest" timestamp="2025-02-06T09:48:35.147Z" tests="1" failures="0" skipped="0" time="1.467" errors="0">
		<testcase name="My Test Case" classname="MyTest" time="6.467">
			<properties>
				<property name="team" value="My team name"></property>
                                <property name="type" value="integration"></property>
			</properties>
		</testcase>
	</testsuite>
</testsuites>

Describe the solution you'd like
Traits can be picked up by the test logger and added as properties.

Depending on the framework, so for ...

... xUnit

[Trait("team", "My team name")]
[Trait("type", "integration")]
class MyTestSuite {
 // tests here
}

... NUnit

[Category("team", "My team name")]
[Category("type", "integration")]
class MyTestSuite {
 // tests here
}

the according trait would be parsed. Eventually this can be made configurable so it would work with any type of decorator?

Describe alternatives you've considered
I could extend the JUnit XML logger, unfortunately, all functionality is private and it's difficult to customize / e.g., add the package as a dependency and customize the logger.

If you opened that up, customization would be possible here, by simply extending that.

Activity

  1. changed the title [-]Custom fields for junit reports[/-] [+]Add support for custom properties in generated junit reports[/+] on Feb 6, 2025
  2. codito commented on Feb 6, 2025

    @codito
    Contributor

    @timo-reymann thank you for the suggestion, this will be a great addition to the junit logger.

    We can follow the implementation similar to NUnit logger (example) and also update the JUnit.xsd.

    If you're open to contributing a fix, please let me know :)

  3. timo-reymann commented on Feb 7, 2025

    @timo-reymann
    ContributorAuthor

    @codito thanks for the swift response - sure thing will have a look and put an PR together :)

  4. timo-reymann commented on Feb 10, 2025

    @timo-reymann
    ContributorAuthor

    @codito created feat: [junit] #153 Add properties support on test case level for test logger #154, please let me know if anthing is wrong / missing 😊

  5. added a commit that references this issue on Feb 11, 2025
  6. codito commented on Feb 11, 2025

    @codito
    Contributor

    Thanks @timo-reymann! I will cut a release this weekend.

  7. codito commented on Feb 14, 2025

    @codito
    Contributor

    JUnitXml.TestLogger v6 with this feature is now on nuget! https://www.nuget.org/packages/JunitXml.TestLogger/6.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions