Using SonarQube 8.9.0.43852 using Jenkins and trying to run a C++ Code Coverage.
I get coverage percentages (using CppCodeCoverage.exe on the code level) but the # Unit Tests stays ‘-’
In the Jenkins log I see the following: 23:19:39 INFO: Parsing […]\TestExecutionReports.xml 23:19:39 INFO: Imported test execution data for 0 files 23:19:39 INFO: Test execution data ignored for 2 unknown files, including: 23:19:39 […]/tst/source/LicenseManagerKernelTest.cpp
The docs are clear that the paths to your test files can be either absolute (i.e. from root) or relative to the project base directory (generally the directory you kicked analysis off from). And I’m sure that when I initially tested this feature I would have tested both. And - not that it should matter - I’m on Linux and I see you’re on Windows. Have you tried this with relative paths?
Also, I notice that your file path contains both kinds of slashes. It’s possible that you need to escape your backslashes:
Hi Ann, thank you for the response!
These backslashes were staring me in the face
Replacing them did not help. Also, relative paths do not work. I keep getting:
INFO: Test execution data ignored for 2 unknown files, including:
applications/cmslicensemanager/logic/cmslicensemanagerkernel/tst/source/LicenseManagerKernelTest.cpp
Do I maybe need to provide an extra property to make these files available?
pathing to the files - does the directory you start analysis from contain applications/cmslicensemanager/logic/&etc?
file type - has LicenseManagerKernelTest.cpp been identified to SonarQube as a test? I.e. is it in the set of files described by the value passed to sonar.tests?
Hi Ann,
I seem to have an issue with the pathing.
Our structure is such that the tests are always a sub-folder of the module it is supposed to test. Thus, there is no separate path for tests.
This may be the reason why I get this:?
ERROR: Error during SonarScanner execution
ERROR: File applications/cmslicensemanager/logic/cmslicensemanagerkernel/tst/source/LicenseManagerKernelTest.cpp can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test
Yes, an overlap of sonar.sources and sonar.tests is the likely culprit here. You can probably work that out with the right combinations of inclusions & exclusions
The files listed as sources of the tests in testExecutions, shall that be ALL the test code files? Are they cpp or h files? Is a wildcard allowed, or a folder?
What is actively DONE with these files? Can I just mention the main test file?
This is because our test code does not actively add the names of the text code files anywhere, so we need to make a rather extensive change.
Ideally, sonar.sources is going to point fully and only to source files, and sonar.tests will point fully and only to test files. And as you’ve discovered, they should not point to the same sets or even overlapping sets of files. Note that both of these parameters expect directory arguments, so you can’t disentangle mixed sets based on file names.