SonarQube Version: 8.9
- what are you trying to achieve
Issues#
- As mentioned in subject, angular tests not counted as part of total counts, only dot net unit tests count only counted and shown on sonar dashboard
– tried multiple options / suggestions provided over community but not succeeded, getting either below info or can’t be indexed twice. check inclusion/exclusion
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for XX unknown files
refer below screenshot, in which expected test count will be more than 127 i.e. it should include angular project test count also, but actually not.
- even when clicked on test count on sonarqube dashboard, which redirects to https://‘XXXXX’.com/sonarqube/component_measures?id=xxxx&metric=tests&view=list, which doesn’t show list of test files underneath test count?
- what have you tried so far to achieve this
Tried Options
- used both options Sonar Scanner with MSBuild and CLI with associated properties respectively, but same result.
INFO: Imported test execution data for 0 files
INFO: Test execution data ignored for XX unknown files
- included SonarQubePrepare@4 at only angular level, i.e. before angular build, and test later sonar analysis and sonar publish task, but same result as above, count shows as ‘-’
Note: But locally, with in VS / from terminal, npm run sonar working at angular project level, but solution level and in build pipeline not working.
do help us know in finding the cause of the above mentioned issues, it will be really helpful and appreciated. thanks in advance.
Project Folder Structure:
Sonar Properties: in Azure Devops Build Pipeline | YAML file
task: SonarQubePrepare@4
displayName: 'prepare sonar qube analysis'
inputs:
SonarQube: 'sonarqube'
scannerMode: 'MSBuild' -- Tried even CLI, its related properties cliProjectKey, cofigemode=manual etc..
projectKey: 'XXXX'
projectName: 'XXXX'
extraProperties: |
sonar.exclusions=**/coverage/**,**/MyCoverage/**,**/obj/**,**/*.dll,**/bin/**,**/dist/**,**/node_modules/**
sonar.cs.opencover.reportsPaths=**/MyCoverage/coverage.opencover.xml
sonar.cs.vstest.reportsPaths=\**\*.trx
sonar.test.inclusions=**/*.spec.ts,**/unittests/**/*Tests.cs
sonar.testExecutionReportPaths=**/coverage/sonar_report.xml
sonar.javascript.lcov.reportPaths=**/coverage/report-lcov/lcov.info
sonar.coverage.exclusions=**/unittests/**,**/*.spec.ts
- task: SonarQubeAnalyze@4
- task: SonarQubePublish@4
inputs:
pollingTimeoutSec: '300'
Karma.conf.js
module.exports = function (config) {
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-junit-reporter'),
require('karma-sonarqube-unit-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageReporter: {
// specify a common output directory
dir: '../coverage',
reporters: [
// reporters not supporting the `file` property
{ type: 'html', subdir: 'report-html' },
{ type: 'lcov', subdir: 'report-lcov' },
// reporters supporting the `file` property, use `subdir` to directly
// output them in the `dir` directory
{ type: 'cobertura', subdir: '.', file: 'cobertura.txt' },
{ type: 'lcovonly', subdir: '.', file: 'report-lcovonly.txt' },
{ type: 'text-summary', subdir: '.', file: 'text-summary.txt' },
]
},
reporters: ['progress', 'kjhtml', 'junit', 'sonarqubeUnit'],
junitReporter: {
outputDir: '../junit'
},
sonarQubeUnitReporter: {
sonarQubeVersion: 'LATEST',
outputFile: '../reports/sonar_report.xml',
overrideTestDescription: true,
testPaths: ['./src'],
testFilePattern: '.spec.ts',
useBrowserName: false
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: false
});
};