Test execution data ignored for files

Hi

I can’t seem to get my coverage from npm jest-sonar-reporter. So i’ll show my setup.

package.json

  "jestSonar": {
    "reportPath": "src",
    "reportFile": "test-reporter.xml",
    "indent": 4
  },

That successfully generate the file in my vue src folder. I’m running sonarQube in docker and the using the runner like so:

docker run -ti -v /Users/jonny/ios/myapp.js:/usr/src  --link sonarqube newtmitch/sonar-scanner -Dsonar.host.url=http://sonarqube:9000   -Dsonar.jdbc.url=jdbc:h2:tcp://sonarqube/sonar   -Dsonar.projectKey=vue   -Dsonar.projectName="vue"   -Dsonar.projectVersion=1   -Dsonar.sources=src -Dsonar.login=722sdc70c79343f17d34d7be33b4d190b446b795 -Dsonar.testExecutionReportPaths="src/test-reporter.xml" -Dsonar.tests=tests -Dsonar.test.inclusions=tests/unit/*.spec.js

My folder structure is like so

app
   - src
   - tests
       - unit
           file.spec.js
           file2.spec.js

The output from the console I see though is this:

INFO: Sensor JavaXmlSensor [java]
INFO: 1 source files to be analyzed
INFO: Sensor JavaXmlSensor [java] (done) | time=491ms
INFO: Sensor HTML [web]
INFO: 1/1 source files have been analyzed
INFO: Sensor HTML [web] (done) | time=67ms
INFO: Sensor XML Sensor [xml]
INFO: 1 source files to be analyzed
INFO: Sensor XML Sensor [xml] (done) | time=1209ms
INFO: 1/1 source files have been analyzed
INFO: Sensor Generic Test Executions Report
INFO: Parsing /usr/src/src/test-reporter.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 2 unknown files, including:
/Users/jonny/ios/myapp.js/tests/unit/helper.spec.js
/Users/jonny/ios/myapp.js/tests/unit/ListFilter.spec.js
INFO: Sensor Generic Test Executions Report (done) | time=99ms
INFO: ------------- Run sensors on project
INFO: Sensor Zero Coverage Sensor
INFO: Sensor Zero Coverage Sensor (done) | time=286ms
INFO: SCM Publisher is disabled

These files generally look like this:

<?xml version="1.0" encoding="UTF-8"?>
<testExecutions version="1">
    <file path="/Users/jonny/ios/myapp.js/tests/unit/helper.spec.js">
        <testCase name="Check header builds properly" duration="16"/>
        <testCase name="Check basic auth header works" duration="3"/>
    </file>
    <file path="/Users/jonny/ios/myapp.js/tests/unit/ListFilter.spec.js">
        <testCase name="TheListFilter.vue renders ok" duration="52"/>
    </file>
</testExecutions>

So just wondering what I need to do to get the coverage into the sonarQube analysis?

1 Like

Hi,

I’m not conversant with docker, so it’s not clear to me from your command line whether you’re running SonarQube itself or the analysis or both. It would make sense to spin up/down a container for analysis, but not for SonarQube.

In looking at your command line, I see that you’re passing sonar.jdbc.url. This hasn’t been needed for analysis for quite some time, and should be dropped.

Now, to your actual question! Why is your test data being ignored? First, in using sonar.testExecutionReportPaths, you’re attempting to pass in Generic Test Execution data. Specifically, which tests passed, which failed, duration, and so on. You’re not providing any coverage reports to analysis that I can see.

Second, your log says this about the report you’re passing in:

What I take from that is that the paths in your report don’t match up to the paths that analysis is seeing. I can only guess this is about reading them in the container context and not having the same root(?).

 
HTH,
Ann

A post was split to a new topic: Trouble with test data