Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarification on if there is support for NUnit? #98

Closed
bhanson-techempower opened this issue Apr 15, 2021 · 11 comments · Fixed by #225 or #232
Closed

Clarification on if there is support for NUnit? #98

bhanson-techempower opened this issue Apr 15, 2021 · 11 comments · Fixed by #225 or #232
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@bhanson-techempower
Copy link

Hi!

In the README summary, it lists NUnit support, but under the supported formats section I do not see an NUnit option.

Can you clarify if there is NUnit support? Thank you!

@dorny
Copy link
Owner

dorny commented Apr 19, 2021

Hi!

Yes it's supported. You just need to get results in trx format instead of NUnit specific XML.

For example like this:
dotnet test --logger "trx;LogFileName=test-results.trx"

@bhanson-techempower
Copy link
Author

Hi Michal!

Oh, I see now, thank you!

Our tests use Unity Test Framework to generate NUnit3 XML files. Unfortunately, it only allows exporting in that format. Rereading the docs again it is pretty clear that the support is for a combination of .NET/NUnit and not NUnit alone. 👍

This looks really great though, nice work!

@dorny
Copy link
Owner

dorny commented Apr 20, 2021

Adding support for another XML format is not so hard.
I will probably add direct support for NUnit once, but I can't promise any exact date.
Any contribution would be very welcome here :)

@Gakk
Copy link

Gakk commented Jun 23, 2021

@dorny I have moved build of several old .NET Framework project to GitHub, and runs NUnit Console Runner directly. I have not found a way for NUnit alone to generate results in TRX, neither any way to transform the default XML to TRX. If you were to implement support for NUnit XML directly this would be great 😃👍

@kf6kjg
Copy link

kf6kjg commented Jun 23, 2021

I got a workaround solved as follows:

      - name: Install NUnit
        run: |
          nuget install NUnit.Console -Version 3.12.0

      - name: Fetch transform code
        run: |
          wget https://raw.githubusercontent.com/nunit/nunit-transforms/master/nunit3-junit/nunit3-junit.xslt
        shell: bash

      - name: Transform NUnit3 to JUnit
        run: |
          Get-ChildItem . -Filter test-results_*.xml | Foreach-Object {
            $xml = Resolve-Path $_.FullName
            $output = Join-Path ($pwd) ($_.BaseName + '_junit.xml')
            $xslt = New-Object System.Xml.Xsl.XslCompiledTransform;
            $xslt.Load("nunit3-junit.xslt");
            $xslt.Transform($xml, $output);
          }
        shell: pwsh

      - uses: dorny/test-reporter@v1.4.2
        with:
          name: "NUnit tests for $1"
          path: "*_junit.xml"
          reporter: jest-junit

You can see the current working workflow at https://github.com/HalcyonGrid/halcyon/blob/master/.github/workflows/test-report.yaml

@Gakk
Copy link

Gakk commented Jun 24, 2021

Thanx @kf6kjg 😀👍

I was not aware of the nunit-transforms library, and it worked great.

For future notice for anyone else reading this: I am running nunit3-console.exe directly and NUnit can then transform directly (as noted on the nunit-transforms library, and you still need to download the xslt-file):

nunit3-console.exe yourTestLib.dll --result="nunit3-junit-testresults.xml;transform=nunit3-junit.xslt"

I also got an error stackTrace.split is not a function when the action tried to parse the result:

image

It worked after switching parser to java-junit (even though it looks like the stack traces from failed tests are missing):

reporter: java-junit

@kf6kjg
Copy link

kf6kjg commented Jun 24, 2021

Excellent. In my case the generation of the xml was split into a different workflow than the analysis of it. Since I prefer that the untransformed file be placed in the artifact storage, I chose to not use the built in transform utility.

@dorny
Copy link
Owner

dorny commented Jun 24, 2021

@Gakk Could you please upload somewhere the TRX or NUnit XML where you got the stackTrace.split is not a function error?
Looks like a bug in the TRX processing.

Anyway, I see there is some demand for NUnit support.
You have found a workaround, but it still unnecessarily complicates the workflow file.
I will have few free days next week, so there's a chance I will finally get to the implementation of NUnit XML support.

@dorny dorny reopened this Jun 24, 2021
@Gakk
Copy link

Gakk commented Jun 25, 2021

@dorny, thanks for the attention and work you are putting into this 👍

The stackTrace.split error was not during parsing of TRX, but parsing of jest-junit. I am running nunit3-console.exe directly and not through dotnet, and therefore does not have the output option of trx(as far as I know).

NUnit have an option to output to junit, but it is not specifying if this is jest-junit or java-junit. @kf6kjg are parsing as jest-junit but I then got an error. Probably because I have unit tests that not only fails on assert but are crashing with a stack trace?

I have added a more detailed comment regarding java-junit on your tracking issue for JUnit support:
#81 (comment)

My result file that ends with the stackTrace.split when parsed as jest-junit error can be found here: nunit3-junit-testresults.zip

If you have time to implement support for the native NUnit3 test result format that would be great 😃👍

@timcassell
Copy link

Is NUnit XML native support still in the works?

@NikMikk
Copy link

NikMikk commented Mar 15, 2024

Is NUnit XML native support still in the works?

I'm curious about this, any updates? I can't get NUnit3 XML to work

@jozefizso jozefizso added this to the v2.0.0 milestone Jun 25, 2024
@jozefizso jozefizso self-assigned this Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
8 participants