Hello,
Can you please help me out with this?
- Sonarqube Version 9.9
Sonar Config:
sonar.projectKey=hk-backend-evolved
sonar.projectName=hk-backend-evolved
sonar.sources=.
sonar.login=
sonar.javascript.lcov.reportPaths=lcov.info
Hello,
Can you please help me out with this?
Sonar Config:
sonar.projectKey=hk-backend-evolved
sonar.projectName=hk-backend-evolved
sonar.sources=.
sonar.login=
sonar.javascript.lcov.reportPaths=lcov.info
Hi,
SonarQube isn’t going to count your tests for you. You need to feed in a test execution report.
HTH,
Ann
Yes but I have provided the LCOV report that is only counting coverage.
Can I share LCOV report with you so that you can better guide me?
Hi,
LCOV reports coverage, not test execution (including test count) metrics.
Ann
which usually file format supports for test execution report?
How can I provide the test files
I have given with the “sonar.tests” but still not visible.
Analysis Properties:
sonar.projectKey=***
sonar.projectName=***
sonar.sources=.
sonar.tests=test/serverisMonit.test.js
sonar.host.url=*****
sonar.projectVersion=1.0
sonar.login=sqp_ba3604bdbb3334ad37785926207426894649f7a8
sonar.exclusions=**/*.java
sonar.javascript.lcov.reportPaths=lcov.info
sonar.coverage.cobertura.xmlReportPaths=/var/lib/jenkins/workspace/Cicd/cobertura-coverage.xml
sonar.test.inclusions=src/**/*.test.js
sonar.sourceEncoding=UTF-8
Hi,
Did you check the links I provided earlier?
Also, you need to revoke that token value you posted above.
Ann
Yes i did and have tried all options provided in the links
Hi,
Care to post your new analysis properties and your analysis log?
The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.
This guide will help you find them.
Ann
Sure
Analysis Properties:
sonar.projectKey=
sonar.projectName=
sonar.sources=.
sonar.tests=./test
sonar.exclusions=**/*.java
sonar.host.url=
sonar.projectVersion=1.0
sonar.login=
sonar.javascript.lcov.reportPaths=lcov.info
sonar.test.inclusions=/var/lib/jenkins/workspace/Cicd/test/test.js
sonar.testExecutionReportPaths=/home/cicdanjalee/hk-backend-evolved/financialsService/test-report.xml
sonar.sourceEncoding=UTF-8
Analysis Logs:
Logs.txt (49.4 KB)
Hi,
I don’t know how many test files you have, but according to your log, two are ignored:
INFO: Test execution data ignored for 2 unknown files, including: /home/cicdanjalee/hk-backend-evolved/financialsService/test/serverisMonit.test.js /home/cicdanjalee/hk-backend-evolved/financialsService/test/server.test.js
Why are these files unknown? Probably because of this:
You’ve created a Venn diagram with no overlap. sonar.tests=./test
(BTW, you don’t need the ./
part of that) says "all the tests are in the test directory.
And then sonar.test.inclusions=/var/lib/jenkins/workspace/Cicd/test/test.js
says "of all the test files (in the test directory) only include [a single file that is not in the test directory]
Also, you’ve once again published an analysis token. You should really redact it.
HTH,
Ann
Yes i do have these two test files only. How to get the unit count from these files?
INFO: Test execution data ignored for 2 unknown files, including:
/home/cicdanjalee/hk-backend-evolved/financialsService/test/serverisMonit.test.js
/home/cicdanjalee/hk-backend-evolved/financialsService/test/server.test.js
So i should remove these two properties?
Hi,
You should remove the inclusions property.
Would you mind sharing why you specified it at all?
Thx,
Ann
Removed the inclusion property but not yet working.
Found some article earlier guiding for this file to add to get the unit test thats why i went with that as well but didn’t work
Hi,
Care to share your new analysis log?
Ann
Here are the updated Analysis Properties:
sonar.projectKey=
sonar.projectName=
sonar.sources=.
sonar.tests=test
sonar.exclusions=**/*.java
sonar.host.url=
sonar.projectVersion=1.0
sonar.login=
sonar.javascript.lcov.reportPaths=lcov.info
sonar.testExecutionReportPaths=/home/cicdanjalee/hk-backend-evolved/financialsService/test-report.xml
sonar.sourceEncoding=UTF-8
Analysis Log:
Logs.txt (5.2 KB)
Build is now getting failed after removing the inclusion property and ./ from sonar.tests property.
Hi,
The error is this:
ERROR: Error during SonarScanner execution ERROR: File test/data/create.json can't be indexed twice. Please check that inclusion/exclusion patterns produce disjoint sets for main and test files
In analysis, first sonar.sources
files are indexed as source files. So in your case, everything in .
, i.e. the current directory. Then sonar.tests
files are indexed. In your case that’s the contents of test
, which is a subset of .
.
So you need to either narrow your sonar.sources
specification, or add an exclusion so that test
isn’t indexed as source files.
HTH,
Ann
What if im adding sonar.tests=.
then?
Hi,
That would be even worse, because then you would be listing every file as both a source file and a test file.
Ann