davidparsson / junit-report-builder

Making it easier to build Jenkins compatible JUnit XML reports
MIT License
23 stars 14 forks source link

Properties for test cases #49

Closed dennisgrck closed 12 months ago

dennisgrck commented 1 year ago

Hello there,

I would like to suggest adding support for properties on a test case level. As more and more tools such as CI and test management tools support test case properties, and as it can be very useful to include additional test attributes for tests, I think it would be a great addition to this project (especially as the downstream projects will be able to use this as well then).

This is also supported by various other test frameworks such as pytest or Playwright, as well as reporting and test management tools such as Testmo.

Properties for test cases

Here is an example of what test case properties look like in the resulting XML file. This is the same format as supported for the testsuite element, just below the testcase element:

<testcase name="testCase3" classname="Tests.Registration" time="3.441">
    <properties>
        <property name="priority" value="high" />
        <property name="language" value="english" />
        <property name="author" value="Adrian" />
        <property name="attachment" value="screenshots/dashboard.png" />
        <property name="attachment" value="screenshots/users.png" />

        <!-- Optional support for properties with text values -->
        <property name="description">
            This text describes the purpose of this test case and provides
            an overview of what the test does and how it works.
        </property>
    </properties>

    <!-- Optional output or error/failure/skipped -->
</testcase>

You can also find additional details on this format here as well as a full XML example file.

As for the API in junit-report-builder, I would suggest using the same API you already have for the test suite element, as it already works well there.

Any feedback welcome!

dennisgrck commented 1 year ago

@davidparsson If you think this would be a useful addition, I would also be happy to implement this and submit a PR to review.

davidparsson commented 1 year ago

Hi! I think this sounds like a great addition, and I'd be happy to accept a pull request for this. The only thing that concerns me a little bit is that I've put in some effort to convert this to TypeScript and add type hints (#24), and I'm not entirely sure of the state of that, but this will obviously introduce conflicts. Please let me check that, and I'll get back to you soon.

dennisgrck commented 1 year ago

Hi David, thanks for the feedback. Sure, sounds good. I'm also happy to wait for the TS conversion eventually and can create a PR for this instead. This would likely make more sense as it's less work for you? Do you think the TS conversion is something that would be completed in a couple of months?

Thanks!

davidparsson commented 1 year ago

I sure hope that I'll be done within a few months, but I can't tell for sure. It's a pretty simple task, although I've run into a few problems. The main issue is that the time I've got to focus on this is very limited.

But if you watch #24 you'll be notified once it's done. Thanks for your patience!

dennisgrck commented 1 year ago

Sounds good, done!

ValentinCondurache commented 1 year ago

@davidparsson any news about this? Is there any way we can add new attributes for test case? I saw that you have this attributes object. Can it be used to add new attributes inside? Thank you!

davidparsson commented 1 year ago

Sorry @ValentinCondurache, but no, there is no public interface for that yet.

It seems I've lost the traction on the TypeScript conversion, so I will accept a PR for this in the projects current state if anybody is willing to provide it.

Pi-fe commented 12 months ago

Hi @davidparsson and @dennisgrck , I create a pull request, if approved you can close this issue.

davidparsson commented 12 months ago

This is fixed in #52 and released today in v3.1.0.