Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to import OpenCover /result in SonarQube?

I'm currently changing things to our Sonar setup since Gallio isn't supported anymore by C# Ecosystem 3. I already successfully imported the unit test coverage by using OpenCover with following command.

"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -register -target:"c:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console-x86.exe" -targetargs:"d:\Sonar\MyTest.dll /noshadow /framework=net-4.0" -output:"d:\Deploy\Sonar\Coverage.xml" "-filter:+[*]* -[*]Test"

With this command I'm only getting the Unit Test Coverage but I would also like to see the number of failed and successful tests. I think I can achieve this with the /result option like

"C:\Program Files (x86)\OpenCover\OpenCover.Console.exe" -register -target:"c:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console-x86.exe" -targetargs:"d:\Deploy\Sonar\MyTest.dll /noshadow /framework=net-4.0 /result=tests.xml"

This command returns an xml with information about the tests that ran but is there any way to import this xml into SonarQube? Or isn't this supported?

Currently I'm importing the Coverage.xml file with the following command:

sonar.cs.opencover.reportsPaths=D:/Deploy/Sonar/Coverage.xml

Is there a similar property to import the tests.xml file with the test results?

like image 755
Nicholas Avatar asked Oct 23 '14 19:10

Nicholas


People also ask

Does SonarQube run unit tests?

By the way, mvn sonar:sonar invokes maven's test goal, which runs unit tests as part of the analysis.

Does SonarQube support .NET core?

SonarScanner for . NET is distributed as a standalone command line executable, as an extension for Azure DevOps Server, and as a plugin for Jenkins. It supports . Net Core on every platform (Windows, macOS, Linux).

How do I test unitar coverage in SonarQube?

SonarQube supports the reporting of test coverage as part of the analysis of your Java project. However, SonarQube does not generate the coverage report itself. Instead, you must set up a third-party tool to produce the report as part of your build process.

How do I get code coverage report in SonarQube?

SonarQube in Action Then we'll start the SonarQube server before running the command mvn sonar:sonar. Once this command runs successfully, it will give us a link to the dashboard of our project's code coverage report: Notice that it creates a file named jacoco. exec in the target folder of the project.


2 Answers

OpenCover is now officially supported by SonarQube, please see the SonarQube documentation. You can pass the location of the XML report OpenCover generated with the command line parameter

/d:sonar.cs.opencover.reportsPaths="%path%\%report_file%"

where %path% is the folder your report file is generated in and %report_file% is the file name of your OpenCover XML report.

like image 150
Paul Kertscher Avatar answered Sep 28 '22 08:09

Paul Kertscher


From the documentation at http://docs.codehaus.org/display/SONAR/C%23+Plugin, it looks like you can import unit test execution reports of MSTest format only.

like image 21
David RACODON - QA Consultant Avatar answered Sep 28 '22 08:09

David RACODON - QA Consultant