'SonarQuve Could not import unit test report for xUnit
I have NET5 xUnit test project. On The build server in CI/CD pipeline I am generating the test coverage report and test execution report with below batch commands. I am using dotnet test to generate reports.
dotnet "C:\sonar-scanner-msbuild-5.5.3.43281-net5.0\SonarScanner.MSBuild.dll" begin /k:"IM" /d:sonar.host.url="myhost.com" /d:sonar.login="xxxxxxx" /d:sonar.cs.opencover.reportsPaths="%WORKSPACE%\Tests\**\TestResults\*\coverage.opencover.xml" /d:sonar.cs.xunit.reportsPaths="%WORKSPACE%\Tests\**\TestResults\TestOutput.xml"
dotnet build "%WORKSPACE%\IM.sln" -nr:false
dotnet test --no-build "%WORKSPACE%\Tests\MyProject1.UnitTests\MyProject.UnitTests.csproj" --logger:trx;LogFileName="%WORKSPACE%\Tests\MyProject1.UnitTests\TestResults\TestOutput.xml" --collect:"XPlat Code Coverage" -- DataCollectionRunSettings.DataCollectors.DataCollector.Configuration.Format=opencover
dotnet "C:\sonar-scanner-msbuild-5.5.3.43281-net5.0\SonarScanner.MSBuild.dll" end /d:sonar.login="xxxxxxx"
This creates two reports...\TestResults\2417ade5-748d-4e44-8129-faa8d64f67b5\coverage.opencover.xml
and...\TestResults\TestOutput.xml
The scanner was able to import coverage report into SonarQube server. However scanner is not able to import test execution report. It throws warning
INFO: Sensor C# Unit Test Results Import [csharp]
INFO: Parsing the XUnit Test Results file '...\TestResults\TestOutput.xml'.
WARN: Could not import unit test report '...\TestResults\TestOutput.xml'
I verified the TestOutput.xml file exists at the given location
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
