Generic test execution data are ignored

1,375 views
Skip to first unread message

Grégory Bittan

unread,
Feb 16, 2018, 4:07:46 AM2/16/18
to SonarQube
I'm trying to import generic test execution with sonar.testExecutionReportPaths. I'm using the xml file format provided in the doc. I use full path to the file in the path attribute. And files exist.

I don't understand why my files are ignored. Any idea ?

I tried both absolute and relative paths in the xml property.

sonar.testExecutionReportPaths = "C:\Program Files (x86)\Jenkins\workspace\CI\Sonarqube.xml"
sonar.test.inclusions = "**\*Test*.cs"
Here is the log from Sonar Runner:

INFO: Sensor Generic Test Executions Report
INFO: Parsing C:\Program Files (x86)\Jenkins\workspace\CI\Sonarqube.xml
WARNING: WARN: Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 5 unknown files, including:
C:\Program Files (x86)\Jenkins\workspace\CI\Tests\A-Test.cs
C:\Program Files (x86)\Jenkins\workspace\CI\Tests\B-Tests.cs
C:\Program Files (x86)\Jenkins\workspace\CI\Tests\C-Tests.cs
C:\Program Files (x86)\Jenkins\workspace\CI\Tests\D-Test.cs
C:\Program Files (x86)\Jenkins\workspace\CI\Tests\E-Test.cs
INFO: Sensor Generic Test Executions Report (done) | time=265ms
Here is the a part of the Generic XMl File:

<testExecutions version="1">
  <file path="C:\Program Files (x86)\Jenkins\workspace\CI\Tests\A-Test.cs">
    <testCase name="My A Test" duration="1210" />
  </file>
  <file path="C:\Program Files (x86)\Jenkins\workspace\CI\Tests\B-Tests.cs">
    <testCase name="My B Test" duration="566" />
  </file>
</testExecutions>

Thank you!

Grégory Bittan

unread,
Feb 19, 2018, 11:44:49 AM2/19/18
to SonarQube
Playing with sonar.test.inclusions / exclusions and sonar.tests. My units tests are displayed on the interface but... Test files are analyzed and Sonarqube and the global report shows "bugs" in test file definitions. When the files are correctly excluded from the report, Tests are not displayed...

G. Ann Campbell

unread,
Feb 21, 2018, 2:11:44 PM2/21/18
to SonarQube
Hi,

When your unit test files are shown in SonarQube, what icon are they given? The one for tests: Or the one for files:


Ann

Grégory Bittan

unread,
Feb 22, 2018, 10:26:36 AM2/22/18
to SonarQube
The first one.

G. Ann Campbell

unread,
Feb 22, 2018, 2:18:25 PM2/22/18
to Grégory Bittan, SonarQube
Hi,

I've become confused by what the actual question is. You started by saying that your test execution report wasn't imported, then switched to inclusion/exclusion of tests, and the fact that issues are raised on them.

First, you shouldn't need to explicitly include your tests; they'll be included by default unless you've somewhere  set an exclusion like **/*.* (which I assume you haven't). Second, if you did need to set inclusions or exclusions, I'd advise you to set them from the UI. As multi-value properties they're tricky to set correctly via parameters. Third, it's natural and expected that if you exclude your tests, no issues will be raised on them. The fact is that there are some rules that apply to tests and some that apply to tests and source code. If you want to keep the rules but suppress the tests issues, then you might want to set an issue exclusion (rather than a blanket exclusion).

All of that is outside what the original email was about, which is the generic test execution reports. From the log file snippet you provided, it seems that the paths you use in the file are unrecognized by SonarQube. In general, the easiest thing to do here is to find A-Test.cs (for instance) in the interface, and look at the path to it as SonarQube understands it, then make sure the report uses that format. 


HTH,
Ann



---
G. Ann Campbell | SonarSource
Product Manager
@GAnnCampbell

--
You received this message because you are subscribed to a topic in the Google Groups "SonarQube" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/sonarqube/kLjAkxYbB0A/unsubscribe.
To unsubscribe from this group and all its topics, send an email to sonarqube+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sonarqube/2dcd80db-244d-4638-a1fe-878314db886d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Grégory Bittan

unread,
Feb 22, 2018, 3:21:08 PM2/22/18
to SonarQube
Hi,

At the beginning, i used only Admin UI to setup parameters and the test execution wasn't imported. I partially solved the issue using /d:sonar.tests in the command line and specifying test directories. Now tests appears. But now test files are analyzed. For example, Sonar detects a bug in my unit tests despite sonar.exclusions = **\*Test*.cs set from the UI.

I can send you a detailed log of the execution.
To unsubscribe from this group and all its topics, send an email to sonarqube+...@googlegroups.com.

Venkata Nandagiri

unread,
Mar 7, 2018, 10:48:03 AM3/7/18
to SonarQube
Please let me know the solution to the problem. I am also facing same issue.

Grégory Bittan

unread,
Mar 8, 2018, 5:50:50 AM3/8/18
to SonarQube
I did a lot configuration

sonar.cs.dotcover.reportsPaths = DotCover.html
sonar.cpd.exclusions = **/*Test*/**/*.cs
sonar.exclusions = **/*.xml
sonar.test.inclusions = **/*Test*.cs
sonar.issue.ignore.multicriteria * | **/*Test*/**


With this configuration, i got good results on a Project but on another one which seems to have the same structure, it failed. Unit Test counter is wrong and Coverage is not accurate.

Hope i could fix
Reply all
Reply to author
Forward
0 new messages