XSLTs for transformating nunit3 TestResult.xml

1,732 views
Skip to first unread message

Paul Hicks

unread,
Feb 10, 2016, 4:43:33 PM2/10/16
to NUnit-Discuss
Publishing nunit3 test results to Jenkins, via nunit2 format and the Jenkins NUnit plugin, is collapsing all data-driven test results (TestCaseSource, etc.) into a single report row. For one of my projects, Jenkins is showing a row with no name and 10000+ test passes. That's actually closer to 100 different tests each with about 100 cases provided via TestCaseSource.

I'm sure I could resolve this by transforming the nunit3 TestResult.xml directly to XUnit format and removing the two existing transforms from the equation. I'm also sure that someone else has already done this.

My searchfu is failing me; I haven't been able to find any XSLTs for the new result file format. Has anyone else come across (or developed!) a suitable xslt? If there isn't one that transforms NUnit3 to XUnit/JUnit, any working NUnit3-compatible xslt file would be a good starting point and I'll have a go at adapting it.

Paul Hicks

unread,
Feb 16, 2016, 10:32:43 PM2/16/16
to NUnit-Discuss
I've written a suitable XSLT for converting NUnit3 results to JUnit-style results. It deliberately drops some information: my intention is to produce a file suitable for publishing to Jenkins via the JUnit publisher.
The NUnit publisher ("NUnit plugin" for Jenkins) requires NUnit2-style results and isn't keeping up with the snazziness of the JUnit plugin. In particular, the JUnit plugin allows for claiming of individual test failures.
XML files produced by transforming NUnit3 results with the attached XLST file are suitable for publishing via the JUnit plugin.

Feel free to distribute as far and wide as you wish. No need to attribute anything to me :)
nunit3-xunit.xslt

Paul Hicks

unread,
Feb 18, 2016, 5:45:12 PM2/18/16
to NUnit-Discuss
Minor update: test-case reason is now assumed to be for an ignored / skipped test, not for a failed test. I haven't found an exception to this rule; after all, test-case failure is used for describing failures!

nunit3-xunit.xslt

Charlie Poole

unread,
Feb 18, 2016, 6:08:26 PM2/18/16
to NUnit-Discuss
Hi Paul,

I sent you a private email about maintaining this as a part of the
nunit-transforms project. Have you received that?

Charlie
> --
> You received this message because you are subscribed to the Google Groups
> "NUnit-Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nunit-discus...@googlegroups.com.
> To post to this group, send email to nunit-...@googlegroups.com.
> Visit this group at https://groups.google.com/group/nunit-discuss.
> For more options, visit https://groups.google.com/d/optout.

Paul Hicks

unread,
Feb 21, 2016, 10:04:44 PM2/21/16
to NUnit-Discuss
This transform is now in the GitHub nunit repo, and any future updates will go there.

Charlie Poole

unread,
Feb 21, 2016, 10:19:06 PM2/21/16
to NUnit-Discuss
Looks good!

We just created this new repo at
https://github.com/nunit/nunit-transforms for contributed XSLT (or
other?) transforms. If you have something that seems generally useful,
feel free to do a PR to add it. We'll review and - if we like it - add
it and give you access to maintain it.

Charlie

On Sun, Feb 21, 2016 at 7:04 PM, Paul Hicks <ten...@gmail.com> wrote:
> This transform is now in the GitHub nunit repo, and any future updates will
> go there.
>
Reply all
Reply to author
Forward
0 new messages