sonar.testExecutionReportPaths not triggering the sensor when run from a gradle subproject

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.

I am having the same issue on a multi-project gradle build.

@zeic did you manage to get it working?

I have not. I had ended up parking this effort in the meantime. I was planning on getting back to it soon though.

@zeic I was able to get this working bu moving the sonar.testExecutionReportPaths property to the root project.

I have my front end in a Maven submodule. The `sonar.testExecutionReportPaths’ property is ignored within the submodule.
When I move the property to the root project. I get the following error, because of the wrong path

[INFO] 18:40:07.431 Parsing /home/xxxxx/git/xxxxxx/webapp-account/target/karma-reports/sonarqube_test_report.xml
[INFO] 18:40:07.446 Imported test execution data for 0 files
[INFO] 18:40:07.446 Test execution data ignored for 7 unknown files, including:
ui/app/global/footer/footer.component.spec.ts
ui/app/global/error-modal/error-modal.component.spec.ts
ui/app/global/header/header.component.spec.ts
ui/app/shared/error/error-interceptor.service.spec.ts
ui/app/global/menu/menu.component.spec.ts

If I missed a solution, let me know.