Jenkins Error in Publishing NUnit Test Results

Running a Unit test is the most common and essential practice of Build automation, however, while publishing NUnit test results, you might get this error “ERROR: Step ‘Publish NUnit test result report’ aborted due to an exception – Caused by: java.io.IOException: Could not transform the NUnit report”

Jenkins - DevOpsBuzz

You should have added the NUnit Test result report step as Post Build action

NUnit test result report

And once you run the job, it will throw an error as below:

20:00:34 C:\Program Files (x86)\Jenkins\workspace\Dev-Build>C:\NUnit.Console-3.6.0\nunit3-console.exe Web\Web.Tests\bin\Debug\Web.Tests.dll Web\Business.Tests\bin\Debug\PMO.Specials.Business.Tests.dll 
20:00:34 NUnit Console Runner 3.6.0 
20:00:34 Copyright (C) 2017 Charlie Poole
20:00:34 
20:00:35 Runtime Environment
20:00:35    OS Version: Microsoft Windows NT 10.0.14393.0
20:00:35   CLR Version: 4.0.30319.42000
20:00:35 
20:00:35 Test Files
20:00:35     Web\Web.Tests\bin\Debug\Web.Tests.dll
20:00:35     Web\Business.Tests\bin\Debug\PMO.Specials.Business.Tests.dll
20:00:35 
20:00:38 
20:00:38 Run Settings
20:00:38     DisposeRunners: True
20:00:38     WorkDirectory: C:\Program Files (x86)\Jenkins\workspace\Dev-Build
20:00:38     ImageRuntimeVersion: 4.0.30319
20:00:38     ImageTargetFrameworkName: .NETFramework,Version=v4.5
20:00:38     ImageRequiresX86: False
20:00:38     ImageRequiresDefaultAppDomainAssemblyResolver: False
20:00:38     NumberOfTestWorkers: 4
20:00:38 
20:00:38 Test Run Summary
20:00:38   Overall result: Passed
20:00:38   Test Count: 349, Passed: 349, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
20:00:38   Start time: 2017-04-27 20:00:35Z
20:00:38     End time: 2017-04-27 20:00:38Z
20:00:38     Duration: 3.734 seconds
20:00:38 
20:00:38 Results (nunit3) saved as TestResult.xml
20:00:39 C:\Program Files (x86)\Jenkins\workspace\Dev-Build>exit 0 
20:00:39 [Dev-Build] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Users\TOOLS-~1\AppData\Local\Temp\********1369824949108280818.ps1'"
20:00:39 Recording NUnit tests results
20:00:39 ERROR: Step ‘Publish NUnit test result report’ aborted due to exception: 
20:00:39 org.xml.sax.SAXParseException; systemId: file:/C:/Program%20Files%20(x86)/Jenkins/workspace/Dev-Build/temporary-junit-reports/temp-junit.xml; lineNumber: 2; columnNumber: 3; Content is not allowed in prolog.
20:00:39 	at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
20:00:39 	at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
20:00:39 	at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
20:00:39 	at hudson.plugins.nunit.NUnitReportTransformer.splitJUnitFile(NUnitReportTransformer.java:102)
20:00:39 	at hudson.plugins.nunit.NUnitReportTransformer.transform(NUnitReportTransformer.java:72)
20:00:39 	at hudson.plugins.nunit.NUnitArchiver.invoke(NUnitArchiver.java:66)
20:00:39 Caused: java.io.IOException: Could not transform the NUnit report. Please report this issue to the plugin author
20:00:39 	at hudson.plugins.nunit.NUnitArchiver.invoke(NUnitArchiver.java:71)
20:00:39 	at hudson.plugins.nunit.NUnitArchiver.invoke(NUnitArchiver.java:29)
20:00:39 	at hudson.FilePath.act(FilePath.java:997)
20:00:39 	at hudson.FilePath.act(FilePath.java:975)
20:00:39 	at hudson.plugins.nunit.NUnitPublisher.perform(NUnitPublisher.java:153)
20:00:39 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
20:00:39 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
20:00:39 	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
20:00:39 	at hudson.model.Build$BuildExecution.post2(Build.java:186)
20:00:39 	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
20:00:39 	at hudson.model.Run.execute(Run.java:1760)
20:00:39 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
20:00:39 	at hudson.model.ResourceController.execute(ResourceController.java:97)
20:00:39 	at hudson.model.Executor.run(Executor.java:405)

First, you need to understand what exactly is causing the error :

Its not the Nunit report ( TestResult.xml )

It’s not either your framework/installation/nunit3-console.exe

Software Configuration - Commonly Used Terms

Its the way Jenkins take this reports – Jenkins tries to transform the NUnit report to JUnit report since its understand only JUnit reports.

While doing that it’s using the default XLST file which is causing the issue.

What you can do?

SD Clipart - DevOpsBuzz

You can use the XSLT written by Paul Hicks. You can download it from this link (Make sure its properly copied with no spaces/extra words – use XML validator to validate)

Then instead of using Jenkins transformed file, use this new xslt file and add the below to NUnit3-console command

–result=TestResult.xml;transform=”C:\nunit3-xunit.xslt”

where,

–result will tell Nunit to save the result in the given name and

transform will transform the result as per Jenkins requirement.

Copy xunit junit - DevOpsBuzz

Once done, just run the build again and this time you see the success.

11:58:08 C:\Program Files (x86)\Jenkins\workspace\Dev-Build>C:\NUnit.Console-3.6.0\nunit3-console.exe Web\Web.Tests\bin\Debug\Web.Tests.dll Web\Business.Tests\bin\Debug\PMO.Specials.Business.Tests.dll --result=TestResult.xml;transform="C:\nunit3-xunit.xslt" 
11:58:08 NUnit Console Runner 3.6.0 
11:58:08 Copyright (C) 2017 Charlie Poole
11:58:08 
11:58:08 Runtime Environment
11:58:08    OS Version: Microsoft Windows NT 10.0.14393.0
11:58:08   CLR Version: 4.0.30319.42000
11:58:08 
11:58:08 Test Files
11:58:08     Web\Web.Tests\bin\Debug\Web.Tests.dll
11:58:08     Web\Business.Tests\bin\Debug\PMO.Specials.Business.Tests.dll
11:58:08 
11:58:12 
11:58:12 Run Settings
11:58:12     DisposeRunners: True
11:58:12     WorkDirectory: C:\Program Files (x86)\Jenkins\workspace\Dev-Build
11:58:12     ImageRuntimeVersion: 4.0.30319
11:58:12     ImageTargetFrameworkName: .NETFramework,Version=v4.5
11:58:12     ImageRequiresX86: False
11:58:12     ImageRequiresDefaultAppDomainAssemblyResolver: False
11:58:12     NumberOfTestWorkers: 4
11:58:12 
11:58:12 Test Run Summary
11:58:12   Overall result: Passed
11:58:12   Test Count: 349, Passed: 349, Failed: 0, Warnings: 0, Inconclusive: 0, Skipped: 0
11:58:12   Start time: 2017-04-28 11:58:08Z
11:58:12     End time: 2017-04-28 11:58:12Z
11:58:12     Duration: 3.993 seconds
11:58:12 
11:58:12 Results (user) saved as TestResult.xml
11:58:12 
11:58:12 C:\Program Files (x86)\Jenkins\workspace\Dev-Build>exit 0 
Jenkins Project Output with Test Result - DevOpsBuzz

6 thoughts on “Jenkins Error in Publishing NUnit Test Results”

  1. Could you please help me out for the following issue:
    git clone is hangs up in Jenkins pipeline.
    git clone ‘repo link’

    1. Hi Venkat,
      Thanks for your query but it doesn’t give much information about the issue, such as

      – which git repo [ External (on-internet) / Internal (onpremises) ] ?
      – gitlab/github/bitbucket or any thing else ?
      – are you able to connect to that git repo directly through Jenkins node ?
      – what is the error you see in logs or when you cancel the job ?
      – is there any firewall issue which is restricting the access ?
      – was it working before ?
      – is there any change in access-keys, user credentials, etc ?

      Once you get the answers of these, you might be able to figure out the issue – if not, then please share these details and we can try to figure out the issue.

      Happy Learning !!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top
Scroll to Top