Context
In an Angular5 project using karma and jasmine for unit testing, I am generating this report file for my unit tests using karma-sonarqube-unit-reporter.
<testExecutions version="1">
<file path="src/app/appponent.spec.ts">
<testCase name="app/appponent.spec.ts should create the app" duration="314"/>
<testCase name="app/appponent.spec.ts should have as title 'Projet de test Angular5'" duration="104"/>
<testCase name="src/app/appponent.spec.ts should render title in a h1 tag" duration="114"/>
</file>
<file path="src/app/client-add/client-addponent.spec.ts">
<testCase name="client-add/client-addponent.spec.ts should create" duration="107"/>
</file>
<file path="app/client.service.spec">
<testCase name="app/client.service.spec #getClients should return an Observable<Client[]>" duration="38"/>
</file>
<file path="src/app/message.service">
<testCase name="app/message.service should be created" duration="35"/>
</file>
</testExecutions>
But when I import it into Sonarqube (v6.7) (via Jenkins), I get the following
INFO: Sensor Generic Test Executions Report
WARN: Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.
INFO: Parsing C:\Users\adminpp\.jenkins\workspace\ELIS JustElis Beta WEB\reports\ut_report.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 4 unknown files, including:
src/app/appponent.spec.ts
src/app/client-add/client-addponent.spec.ts
src/app/client.service.spec
src/app/message.service
INFO: Sensor Generic Test Executions Report (done) | time=110ms
Here are my sonar properties for excluding and including sources and test codes.
sonar.sourceEncoding=UTF-8
sonar.sources=.
sonar.exclusions=**/node_modules/**
sonar.test.inclusions = **/*.spec.ts
sonar.import_unkown_files=true
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=reports/ut_report.xml
I checked and I have my *.spec.ts files where they are supposed to be.
Questions
Why Sonarqube doesn't find my files?
Have I missed a property or an important step?
(Is this property sonar.test.inclusions = **/*.spec.ts
important?)
Context
In an Angular5 project using karma and jasmine for unit testing, I am generating this report file for my unit tests using karma-sonarqube-unit-reporter.
<testExecutions version="1">
<file path="src/app/app.ponent.spec.ts">
<testCase name="app/app.ponent.spec.ts should create the app" duration="314"/>
<testCase name="app/app.ponent.spec.ts should have as title 'Projet de test Angular5'" duration="104"/>
<testCase name="src/app/app.ponent.spec.ts should render title in a h1 tag" duration="114"/>
</file>
<file path="src/app/client-add/client-add.ponent.spec.ts">
<testCase name="client-add/client-add.ponent.spec.ts should create" duration="107"/>
</file>
<file path="app/client.service.spec">
<testCase name="app/client.service.spec #getClients should return an Observable<Client[]>" duration="38"/>
</file>
<file path="src/app/message.service">
<testCase name="app/message.service should be created" duration="35"/>
</file>
</testExecutions>
But when I import it into Sonarqube (v6.7) (via Jenkins), I get the following
INFO: Sensor Generic Test Executions Report
WARN: Property 'sonar.genericcoverage.unitTestReportPaths' is deprecated. Please use 'sonar.testExecutionReportPaths' instead.
INFO: Parsing C:\Users\adminpp\.jenkins\workspace\ELIS JustElis Beta WEB\reports\ut_report.xml
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for 4 unknown files, including:
src/app/app.ponent.spec.ts
src/app/client-add/client-add.ponent.spec.ts
src/app/client.service.spec
src/app/message.service
INFO: Sensor Generic Test Executions Report (done) | time=110ms
Here are my sonar properties for excluding and including sources and test codes.
sonar.sourceEncoding=UTF-8
sonar.sources=.
sonar.exclusions=**/node_modules/**
sonar.test.inclusions = **/*.spec.ts
sonar.import_unkown_files=true
sonar.typescript.lcov.reportPaths=coverage/lcov.info
sonar.testExecutionReportPaths=reports/ut_report.xml
I checked and I have my *.spec.ts files where they are supposed to be.
Questions
Why Sonarqube doesn't find my files?
Have I missed a property or an important step?
(Is this property sonar.test.inclusions = **/*.spec.ts
important?)
-
1
can you try to add property
sonar.tests=.
(value set to current directory) – Tibor Blenessy Commented Mar 28, 2018 at 17:08 -
@TiborBlenessy I added this property but I got
ERROR: Error during SonarQube Scanner execution ERROR: File .angular-cli.json can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
Maybe because I addedsonar.tests=.
ANDsonar.sources=.
which makes Sonar index files twice (one for test and one for source)? – A. Gorin Commented Mar 29, 2018 at 7:14 -
@TiborBlenessy My bad, I deleted this property
sonar.test.inclusions=**/*.spec.ts
since I thought it would not be necessary anymore and that's what gave me an error. Now that I have these two properties, sonar finds my files. Do you know how these two are related and why i need both? – A. Gorin Commented Mar 29, 2018 at 7:29
2 Answers
Reset to default 4can you try to add property sonar.tests=. (value set to current directory) – Tibor Blenessy
Adding this property in the sonar config worked for me.
I got an error when I had the property sonar.tests
set but not sonar.test.inclusions
though but with the two, everything works fine.
I fix it with adding prefix of absolute path and hope it can help you.
sonarQubeUnitReporter: {
sonarQubeVersion: "9.x",
outputFile: "./coverage/unit-test-result.xml",
overrideTestDescription: true,
testFilePattern: ".spec.ts",
useBrowserName: false,
prependTestFileName: __dirname
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745276681a4620084.html
评论列表(0条)