Code Coverage: no data for Test Executions

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 ‘-’
image

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

My TextExecutions.xml looks like this:

<testExecutions version="1">
  <file path="d:\jenkins\workspace\CmsLicenseManager_QA/source/cms6/source/applications/cmslicensemanager/logic/cmslicensemanagerkernel/tst/source/LicenseManagerKernelTest.cpp">
    <testCase name="LicenseManagerGuiTest" duration="0.004" />
    <testCase name="LicenseManagerGui_AT_1" duration="0.003" />
  </file>

[.. more files]
</testExecutions>

What do you expect in ‘path’ and how do you use it? The documentation is not clear on this.
Thanks in advance,
Marco

Hi Marco,

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:

d:\\jenkins\\workspace\\CmsLicenseManager_QA/source/&etc

As you know, the Scanners are Java programs, & I know Windows backslash paths have been tricky in the past.

 
HTH,
Ann

Hi Ann, thank you for the response!
These backslashes were staring me in the face :open_mouth:
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?

Hi,

There are 2 parts to this equation:

  • 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?

 
Ann

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

Hi,

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

 
HTH,
Ann

Hi Ann,
that worked, thanks for the support!

Still some items are unclear to me:

  • 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.

Thanks in advance,
Marco

Hi Marco,

I don’t fully understand the questions.

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.

 
HTH,
Ann