dotcover and nunit results
Completed
I'm scripting execution of dotcover with nunit on our build server agents. I need both the nunit test results output and the dotcover coverage report (HTML). I'm currently running nunit and dotcover analyze with HTML output. This results in the nunit tests being run twice, once by nunit to produce the test results and once by dotcover instrumented for coverage.
Is there a way to get the nunit test results from dotcover? It would be nice if I only had to run the tests once.
Please sign in to leave a comment.
Hello Richard,
dotCover does not interfere with nunit logs in any way. Could you tell us a little bit more about your configuration? What build server do you use? How do you launch dotCover?
We're running standalone Windows build servers that serve Jenkins masters but we run everything through command line invocation, not Jenkins plugins. Not optimal but that's how the Jenkins guys decided to do it.
I'm running NUnit and creating a testresults.xml out of there, then running dotCover Analyze. I get the coverage report out of dotCover but since dotCover runs the unit tests I was hoping I could get the equivalent to testresults.xml out of dotCover and eliminate the NUnit step. I've tried a bunch of the output formats but I only see coverage, not detailed unit test results.
Is this possible?
In fact dotCover does not run unit tests. It runs nunit-console to do this work. I suppose your command like looks like this:
dotCover.exe analyze /TargetExecutable=nunit-console.exe ... /TargetArguments=[tests] /Output=...
TargetArguments here - are arguments that will be passed to TargetExecutable. So just add nUnit report generation switch to TargetArguments. Something like this:
dotCover.exe analyze... /TargetArguments="[tests] --report testresults.xml" ...
For dotCover I'm running:
tests.xml is not the same as nunit.xml. It appears tests.xml is XML of the coverage reporting while nunit.xml is the unit test detail. I'd like to eliminate step 1 if there's a way to get something equivalent to nunit.xml out of dotCover...
I have created a sample project for you. Just restore/build solution. And then launch Example.bat from solution root directory
Please note that I am using slightly outdated nunit/dotcover versions here. This is to be 100% sure that this sample will work fine on almost any machine
OK. I see what you're doing... The "/result" is for the nunit being run by dotCover, the "/output" is the dotCover output.
I'm running this on my desktop against one of our apps:
dotCover.exe cover /TargetExecutable="nunit3-console.exe"
/result="nunit2.xml;format=nunit2"
/TargetArguments="VendorTester.dll"
/Output="CoverageData.dcvr"
Paths shortened for readability.
I'm getting the dcvr file but not the nunit2.xml file. I need to run V3 since that's what our people are using but I need V2 output for Sonarqube.
Try this:
dotCover.exe cover /TargetExecutable="nunit3-console.exe"
/TargetArguments=""VendorTester.dll" /result="nunit2.xml;format=nunit2""
/Output="CoverageData.dcvr"
Note double quotes I used to escape TargetArguments
That worked.
Is there a way to get the return code from NUnit so I can tell if any tests failed? If I have that then I'm done.
Thanks.
Just Add
to dotCover command line
Great! Thanks.