I have an issue about Sonarqube Count of Unit Test corretly. My project’s backend is .net core web api project and frontend is VueJs project. I wrote unit test both of them. But I can not see total unit tests number after Sonarqube scanner. I run Sonarqube Scanner on Azure Pipelines.
My sonarqube.properties is:
sonar.verbose=true
sonar.cs.vstest.reportsPaths=$(System.DefaultWorkingDirectory)\**\*.trx
sonar.cs.opencover.reportsPaths=$(System.DefaultWorkingDirectory)\**\*.opencover.xml
sonar.typescript.tsconfigPath=<absolute-path>/tsconfig.json
sonar.javascript.lcov.reportPaths=<absolute-path>/lcov.info
sonar.testExecutionReportPaths=<absolute-path>/test-sonar-reporter.xml
sonar.sources=<absolute-path>/src
sonar.tests=<absolute-path>/tests
sonar.test.inclusions=$(System.DefaultWorkingDirectory)/**/*.spec.ts
By the way, I have got 15 .net core unit tests and 1 vuejs unit test.
My package.json file is:
"devDependencies": {
...
"@types/jest": "26.0.14",
"jest-junit": "^12.0.0",
"jest-sonar-reporter": "^2.0.0",
"@vue/test-utils": "1.1.0",
"@vue/cli-plugin-unit-jest": "4.5.7",
},
"jest-junit": {
"outputDirectory": "./coverage/test-results",
"outputName": "test-reports-junit.xml"
},
"jestSonar": {
"reportPath": "./coverage/test-results",
"reportFile": "test-sonar-reporter.xml",
"indent": 4
}
And jest.config.js is
module.exports = {
preset: '@vue/cli-plugin-unit-jest/presets/typescript-and-babel',
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{ts,vue}',
'!src/main.ts', // No need to cover bootstrap file
],
coverageReporters: ["json", "lcov", "text", "clover", "cobertura"],
reporters: [ "default", "jest-junit" ],
testResultsProcessor: "jest-sonar-reporter"
}
After Sonarqube scanner, Code coverages are shown correctly.
And then, I expect 16 Unit tests but written 15 Unit tests, can you help me about this.