Unit test count for TypeScript project

Hello,

Currently my team is using SonarQube.

In Analysis Scope we added test file inclusion (sonar.test.inclusions). We have also added XML coverage report (sonar.javascript.lcov.reportPath). The code and the tests are written in Typescript. In Overall Code tab the coverage of our code looks good except the number of Unit Test is presented as ‘-‘ (screenshot attached). Should we do anything else to get the number of tests displayed correctly?
image

Hey there.

You’ll need to feed test execution reports to the scanner.

1 Like

Hello,
I provided the parameters you mentioned in the above link. please check the attached picture.

Jenkins log
14:29:50.780 + /var/Jenkins50/tools/hudson.plugins.sonar.SonarRunnerInstallation/sonar-scanner_3.1.0.1141/bin/sonar-scanner -Dsonar.host.url=https://sonarqube.XXX.net -Dsonar.login=**** -Dsonar.java.coveragePlugin=jacoco -Dsonar.dynamicAnalysis=resuseReports -Dsonar.coverage.jacoco.xmlReportPaths=target/site/jacoco/jacoco.xml -Dsonar.language=Typescript -Dsonar.projectName=MSKDAMTT-Analyze-CLI -Dsonar.projectKey=MSKDAMTT-Analyze-CLI -Dsonar.sourceEncoding=UTF-8 -Dsonar.testExecutionReportPaths=/var/Jenkins50/workspace/T_Analyze_for_Zowe_CLI_sonarqube/tests/results/unit/jest-sonar/test-report.xml -Dsonar.javascript.lcov.reportPaths=tests/results/unit/coverage/lcov.info -Dsonar.tests=src -Dsonar.sources=src -Dsonar.branch.name=sonarqube

@Colin did you get a chance to check the configuration I posted?

Is this a bug ? because I also get coverage but Unit test count doesn’t show.

I am also facing same issue for Typescript/Javascript projects. We tried Karma, Jest and Jasmine tools but unit test count is not showing.

I am also facing the same issue.
image

Hey there.

You’ll have to find a tool that exports unit test reports in SonarQube’s Generic Test Execution Format format. I’m not aware of any ones right now that are actively maintained.

To be honest, all this does is put the count of Unit tests on your dashboard. We don’t think it’s particularly useful and will probably remove it at some point.

1 Like

Why shouldn’t it be possible for sonarqube to count the testnames in the lcov file?
I don’t see why such a basic functionality should need additional converters