Hello everybody,
My CI environment is running SonarQube 7.9.1 with sonar-scanner-msbuild-4.6.2.2108-net46 .
I am trying to include code coverage and unit test execution results in my analysis. After a bit of struggle I managed to get reports into it and I get correct numbers:
Please don’t mind the actual numbers. They are… uhmm… subject to change But unit tests details still remain empty. After googling and reading I found hints about sonar.tests
et al. not being set, and I tried to set these, but I am probably doing something wrong because I get analysis errors. I run scanner with verbose logging and here are some excerpts from scanner log:
[exec] Starting 'c:\jenkins\workspace\MyPortal_v30_Sonar\tools\sonar-scanner-msbuild-4.6.2.2108-net46\SonarScanner.MSBuild.exe (begin /k:MyPortal_v30 "/n:MyPortal v30" /v:20200314_1951 /d:sonar.sources=c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/MyExchange,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/MyExchange.Installer,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/CommonNet,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/MyAdmin,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/DesignSpace,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/Integrations,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/NMyClient,c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30/Tools /d:sonar.tests=c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\UnitTests /d:sonar.exclusions=c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\UnitTests/**/* /d:sonar.tests.inclusions=c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\UnitTests/**/* /d:sonar.cs.nunit.reportsPaths=c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\TestResult_nunit3.xml /d:sonar.cs.opencover.reportsPaths=c:\jenkins\workspace\MyPortal_v30_Sonar\coverage_report.xml /d:sonar.verbose=true)' in 'c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30'
[...snip...]
[exec] sonar.sources=c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/MyExchange,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/MyExchange.Installer,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/CommonNet,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/CpAdmin,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/DesignSpace,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/Integrations,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/NMyClient,c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30/Tools
[exec] sonar.tests=c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30\\MyExchangeTest\\UnitTests
[exec] sonar.exclusions=c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30\\MyExchangeTest\\UnitTests/**/*
[exec] sonar.tests.inclusions=c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30\\MyExchangeTest\\UnitTests/**/*
[exec] sonar.cs.nunit.reportsPaths=c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\sw\\pceapp\\my\\MyPortal\\rel\\v30\\MyExchangeTest\\TestResult_nunit3.xml
[exec] sonar.cs.opencover.reportsPaths=c:\\jenkins\\workspace\\MyPortal_v30_Sonar\\coverage_report.xml
[...snip...]
[exec] 20:03:26.993 INFO: Indexing files of module 'UnitTests.Base'
[exec] 20:03:26.993 INFO: Base dir: C:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\UnitTests\UnitTests.Base
[exec] 20:03:26.994 DEBUG: Source paths: Asserts/AuthorizationAssert.cs, [...snip...]
[exec] 20:03:26.994 DEBUG: Test paths: c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\UnitTests
[exec] 20:03:26.994 INFO: Excluded sources: c:\jenkins\workspace\MyPortal_v30_Sonar\sw\pceapp\my\MyPortal\rel\v30\MyExchangeTest\UnitTests/**/*
[exec] 20:03:26.996 DEBUG: Evaluate issue exclusions for 'MyExchangeTest/UnitTests/UnitTests.Base/Asserts/AuthorizationAssert.cs'
[exec] 20:03:26.997 DEBUG: 'MyExchangeTest/UnitTests/UnitTests.Base/Asserts/AuthorizationAssert.cs' generated metadata with charset 'UTF-8'
[exec] 20:03:26.997 DEBUG: 'MyExchangeTest\UnitTests\UnitTests.Base\Asserts\AuthorizationAssert.cs' indexed with language 'cs'
...snip...
[exec] 20:03:27.139 DEBUG: Evaluate issue exclusions for 'MyExchangeTest/UnitTests/UnitTests.Base/Asserts/AuthorizationAssert.cs'
[exec] 20:03:27.139 DEBUG: 'MyExchangeTest/UnitTests/UnitTests.Base/Asserts/AuthorizationAssert.cs' generated metadata as test with charset 'UTF-8'
[exec] 20:03:27.147 INFO: ------------------------------------------------------------------------
[exec] 20:03:27.147 INFO: EXECUTION FAILURE
[exec] 20:03:27.147 INFO: ------------------------------------------------------------------------
[...snip...]
[exec] 20:03:27.235 ERROR: Error during SonarQube Scanner execution
[exec] 20:03:27.235 ERROR: File MyExchangeTest/UnitTests/UnitTests.Base/Asserts/AuthorizationAssert.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
Maybe all I need is just another pair of eyes because I cannot see why sources and conditions would not be disjoint, setting source exclusions and test inclusions to the exactly same values. But still, AuthorizationAssert.cs
(which a very first source file of the very first test project being analyzed) is indexed twice, both as source and as test.
What am I missing here? What do I need to do to get unit tests result into my analysis details?
Thanks for any help, and best regards!