-
Notifications
You must be signed in to change notification settings - Fork 362
sonar.cxx.nunit.reportPaths
Sensor to read reports from the NUnit testing framework . NUnit is a unit-testing framework for all .Net languages, initially ported from JUnit.
Many C++ developers use NUnit to develop component tests, especially in the context of the Component Object Model (COM) developed by Microsoft.
Meanwhile, NUnit support is part of SonarQube. If possible sonar.cs.nunit.reportsPaths should be used.
Note: The cxx plugin itself does not run any tools, you have to do that yourself beforehand. The sensor only reads the report generated by a tool!
- Link to the tool page: https://nunit.org/
- The sensor supports NUnit with version 2.
In order to generate a fitting report, make sure:
- that the paths in the report matches the
sonar.sources
andsonar.tests
lists insonar-project.properties
- the path can be absolute or relative to the project base directory
NUnit provides three different runners, which may be used to load and run your tests. The Console Runner, nunit-console.exe, is used for batch execution.
Sample command lines:
nunit3-console.exe MyTests.dll --result="report.xml;format=nunit2" --labels=ALL ...
If the tool was executed successfully, a report like the example below should be generated:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<!--This file represents the results of running a test suite-->
<test-results name="c:\git\sonar-nunit\Sonar.NUnit\bin\Debug\Sonar.NUnit.dll" total="200" errors="30" failures="20" not-run="5" inconclusive="4" ignored="3" skipped="2" invalid="1" date="2014-08-15" time="09:02:13">
<environment nunit-version="2.6.0.12051" clr-version="2.0.50727.5483" os-version="Microsoft Windows NT 6.1.7601 Service Pack 1" platform="Win32NT" cwd="c:\git\sonar-nunit" machine-name="machine" user="user" user-domain="domain" />
<culture-info current-culture="en-GB" current-uiculture="en-US" />
<test-suite type="Assembly" name="C:\sonar-examples\projects\languages\csharp\NUnitTestProject1\bin\Debug\NUnitTestProject1.dll" executed="True" result="Success" success="True" time="0.051" asserts="0">
<results>
<test-suite type="Namespace" name="NUnitTestProject1" executed="True" result="Success" success="True" time="0.046" asserts="0">
<results>
<test-suite type="TestFixture" name="NUnitTest1" executed="True" result="Success" success="True" time="0.045" asserts="0">
<results>
<test-case name="NUnitTestProject1.NUnitTest1.NUnitTestMethod1" executed="True" result="Success" success="True" time="0.041" asserts="2" />
</results>
</test-suite>
</results>
</test-suite>
</results>
</test-suite>
</test-results>
- First check if the file extensions read in by the cxx plugin are set (sonar.cxx.file.suffixes).
- That the paths in the report matches the
sonar.sources
andsonar.tests
lists insonar-project.properties
. - Set the analysis parameter
sonar.cxx.nunit.reportPaths
in the configuration filesonar-project.properties
of your project. The Report Paths link describes the configuration options. - Execute the SonarScanner to transfer the project with the report to the SonarQube Server.
Sample for sonar-project.properties:
sonar.cxx.nunit.reportPaths=report.xml
- If scanning is failing, check items listed under Troubleshooting Configuration.