Must-share information (formatted with Markdown):
- which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
Server ID 10173C1E-AW-OunQtiDNiDb7hDFkk Version 18.104.22.168237 SonarCFamilyLANGUAGES Code Analyzer for C, C++, Objective-C 6.5.0 (build 12506)installed I currentlty have a 2 week trial edition of the developer edition
- what are you trying to achieve
I try to see unittest and source files as code in sonarqube and using a static xml generic test execution format file to display the tests. Currently I get no test files under source when I include sonar.tests=testfolder and when I set sonar.tests.inclusions. Then it dissapear under code.
- what have you tried so far to achieve this
I created folder named dotnet_test9 In here is a dontnet solution file. the structure is as follows ./projectfolder\project.project ( dotnet) ./projectfolder\source ./projectfolder\tests
The sonarqube output
12:21:51.418 INFO: Project configuration: 12:21:51.418 INFO: Excluded sources: **/tests/** 12:21:51.419 INFO: Included tests: **/tests/** 12:21:51.419 INFO: Excluded tests: **/source/** 12:21:51.424 INFO: Indexing files of module 'projectfolder' 12:21:51.424 INFO: Base dir: C:\dotnet_test9\projectfolder 12:21:51.426 DEBUG: Source paths: Resources.Designer.cs, source/ui_steps.cs, tests/UnitTest1.cs, Resources.resx, , TestResults/UITEST_RESULTS.trx, TestResults/UI_TP.xml, UI_TP.xml
with the static UI_TP.xml
<testExecutions version="1"> <file path="projectfolder/tests/UnitTest1.cs"> <testCase name="TestMethod1" duration="5"/> </file> <file path="tests/UnitTest1.cs"> <testCase name="TestMethod1" duration="5"/> </file> <file path="UnitTest1.cs"> <testCase name="TestMethod1" duration="5"/> </file> </testExecutions>
sonar scanner commands:
SonarScanner.MSBuild.exe begin /k:"test_csharp" /d:sonar.host.url="http://10.10.20.211:9001" /d:sonar.login="c320e5a096e03bdfb82a4c51fb8728a6b89f097c" MsBuild.exe /t:Rebuild SonarScanner.MSBuild.exe end /d:sonar.login="c320e5a096e03bdfb82a4c51fb8728a6b89f097c"
Error I notice:
12:21:55.579 INFO: Imported test execution data for 0 files 12:21:55.580 INFO: Test execution data ignored for 3 unknown files, including: projectfolder/tests/UnitTest1.cs tests/UnitTest1.cs UnitTest1.cs
extra config in sonarqubeanalysis.xml in sonarscanner folder
Any clue? Why it doesnt want to import the generic test report. the xml is checked against the sonarqube documenation listed here:
sonarqube documentation generic test execution
and why I cant see the tests/Unittest1 under code in sonarqube
Also whenever I try to change sonar.exclusions I always get unittest.cs file cant be indexed twice.
Even when I put a configuration inside SonarQube web configuration in analysis scope to exclude or include.
Notice currently I dont have put anything in the analysis scope in SonarQube itself.
When I add the sonar.tests variable for with sonar.tests = tests
Then I get always this
13:25:23.425 ERROR: Error during SonarQube Scanner execution 13:25:23.312 DEBUG: Test paths: tests 13:25:23.312 INFO: Excluded sources: **/tests/** 13:25:23.312 INFO: Included tests: **/tests/** File tests/UnitTest1.cs can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
But the log tells me
13:27:02.593 DEBUG: Test paths: tests 13:27:02.594 INFO: Excluded sources: **/tests/**, **/tests/** 13:27:02.594 INFO: Included tests: **/tests/** 13:27:02.594 INFO: Excluded tests: **/source/** 13:27:02.596 DEBUG: 'tests/UnitTest1.cs' generated metadata as test with charset 'UTF-8'
that they are correct excluded ?
I suspect the error is telling in the source we analysed the unittest already?
so we cant do it in the tests again, but they are excluded!! ? it breaks my mind lol
maybe this could be?
13:30:26.950 INFO: Indexing files of module 'SMT_CORE_UI_TESTS' 13:30:26.950 INFO: Base dir: C:\dotnet_test9\projectfolder 13:30:26.952 DEBUG: Source paths: Resources.Designer.cs, source/ui_steps.cs, tests/UnitTest1.cs, Resources.resx, UI_TP.xml 13:30:26.953 DEBUG: Test paths: tests 13:30:26.953 INFO: Excluded sources: **/tests/**, **/tests/** 13:30:26.953 INFO: Included tests: **/tests/** 13:30:26.953 INFO: Excluded tests: **/source/**
I notice it sees the source paths test/
While in my exclude I put **/tests/** except ** would be a wildcard to find more not?
nope adding , tests to the sonar.tests didnt solve it either.
removing sonar.tests and all exclusions and inclusions.
I get this:
But now the tests folder files are not listed as tests just as normal source.
When I add back the execution report path and the import unknow files
I get this:
it sounds fair, cause I didnt said sonar.tests = tests folder but whenever I do that I get all these problems above in the topic.
then when i add
plus the tests dissapear now in code folder in sonarqube dashboard