Angular projects Unit test cases

(Sai Kiran ) #1

Hi Team,

In the organization I work for, we are using Jasmine and Karma for writing the unit test cases for Angular projects. For those projects the unit test cases are not shown in the sonarcloud, where as the coverage for those projects is shown.
Is there any way we can get the unit test cases metric in sonarcloud.
Any help is appreciated.

Thanks,

(Elena Vilchik) #3

Hi,

Yep, there is a way:) You should rely on generic code coverage https://sonarcloud.io/documentation/analysis/generic-test/
Property is sonar.testExecutionReportPaths. See this project https://github.com/tobiashofmann/karma-sonarqube-generic-reporter for convertion (note it’s a community project, not maintained by SonarSource)

(Sai Kiran ) #4

Hi Elena,

Appreciate your reply.
My concern here is in respect to the missing unit test cases number for Angular projects which are not visible on sonarcloud unlike the regular dot net projects. please find the below screenshot for the same.
1st image is the dotnet projects report and the bottom image is the angular projects report.
image

Is there any way that we can see the unit test metrcis on sonarcloud UI for angular projects also.
For dot net projects we are using VSTest Assemblies task. And for Angular projects we are obtaining the report from Karma.

Our Organziation Setup:
Azure DevOps with SonarCloud.

Any help is appreciated!

(Elena Vilchik) #5

Did you provide sonar.testExecutionReportPaths property for second project?
What is in the logs?

You should follow such scheme:

  1. generate Karma report
  2. convert this report to generic format
  3. set path to this converted report as the value for sonar.testExecutionReportPaths property
  4. run analysis