I am using SonarQube 7.7 and Gradle 5.4.1 (tested with different versions of Gradle with no change in outcome)
I have a simple angular project configured to use karma to generate generic test results along with the standard lcov report.
I wrapped the angular project in a Gradle project. If I run the project with the below build.gradle configuration I see the generic test information along with the coverage data (SonarQube overview results shown in pic below)
plugins {
id 'org.sonarqube' version '2.7.1'
}
// sonarqube properties
sonarqube {
properties {
property 'sonar.host.url', '<host url>'
property 'sonar.login', '<login token>'
property 'sonar.sources', 'src'
property 'sonar.exclusions', '**/*.spec.ts'
property 'sonar.tests', 'src'
property 'sonar.test.inclusions', '**/*.spec.ts'
property 'sonar.typescript.lcov.reportPaths', 'coverage/lcov.info'
property 'sonar.testExecutionReportPaths', 'coverage/sonar-test-results.xml'
}
}
apply plugin: 'base'
// Project Settings
group = 'launcher'
version = '0.0.1-SNAPSHOT'
task npmInstall(type: Exec) {
executable = 'npm';
args = ['install'];
}
task ngBuild(type: Exec) {
executable = 'npm';
args = ['run', 'build'];
}
task unitTest(type: Exec) {
executable = 'npm';
args = ['run', 'test'];
}
// wire ui tasks into build execution process
tasks.assemble.dependsOn('npmInstall')
tasks.check.dependsOn('unitTest')
tasks.build.dependsOn('ngBuild')
wrapper {
jarFile = rootProject.file('.gradle-wrapper/gradle-wrapper.jar')
}
The processing of the generic test information is seen in the debug log of the Gradle scanner plugin output:
[DEBUG] [org.sonarqube.gradle.SonarQubeTask] Sensors : SonarCSS Metrics → SonarCSS Rules → JavaXmlSensor → HTML → SonarTS → SonarTS Coverage → JaCoCo XML Report Importer → SonarJS → ESLint-based SonarJS → Generic Test Executions Report → JavaSecuritySensor → CSharpSecuritySensor → PhpSecuritySensor
Now if I move to a multi-project Gradle build as show in the following build.gradle, move my angular project to a subproject called launcher-app, and add an include ‘launcher-app’ in my settings.gradle, I get the coverage from the lcov, but no unit test results (overview page shows only the 42.9% coverage and not the 3 unit tests)
plugins {
id 'org.sonarqube' version '2.7.1'
}
// sonarqube global properties
sonarqube {
properties {
property 'sonar.host.url', '<host url>'
property 'sonar.login', '<login token>'
}
}
allprojects {
apply plugin: 'base'
}
// Project Settings
group = 'launcher'
version = '0.0.1-SNAPSHOT'
project(':launcher-app') {
// sonarqube specific properties
sonarqube {
properties {
property 'sonar.sources', 'src'
property 'sonar.exclusions', '**/*.spec.ts'
property 'sonar.tests', 'src'
property 'sonar.test.inclusions', '**/*.spec.ts'
property 'sonar.typescript.lcov.reportPaths', 'coverage/lcov.info'
property 'sonar.testExecutionReportPaths', 'coverage/sonar-test-results.xml'
}
}
task npmInstall(type: Exec) {
executable = 'npm';
args = ['install'];
}
task ngBuild(type: Exec) {
executable = 'npm';
args = ['run', 'build'];
}
task unitTest(type: Exec) {
executable = 'npm';
args = ['run', 'test'];
}
// wire ui tasks into build execution process
tasks.assemble.dependsOn('npmInstall')
tasks.check.dependsOn('unitTest')
tasks.build.dependsOn('ngBuild')
}
wrapper {
jarFile = rootProject.file('.gradle-wrapper/gradle-wrapper.jar')
}
The lack of processing of the generic test information is seen in the debug log of the gradle scanner output:
[DEBUG] [org.sonarqube.gradle.SonarQubeTask] Sensors : SonarCSS Metrics → SonarCSS Rules → JavaXmlSensor → HTML → SonarTS → SonarTS Coverage → JaCoCo XML Report Importer → SonarJS → ESLint-based SonarJS
Is there something I have misconfigured? Is this an issue with a version of SonarQube or the SonarQube Gradle plugin combination I’m using? I have tried different versions of the Gradle SonarQube plugin as far back as 2.6 and still get the same results.
I need to be able to support the use of a multi-project Gradle setup and still have all the proper analysis content displayed in SonarQube. Any and all help is greatly appreciated.