How to setup Angular6 codecoverage from AzureDevOps

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension) : SonarQube

  • what are you trying to achieve : I am trying to setup SonarQube Code coverage using Azure devops but for some reason code coverage just shows 0.
    not sure what step i am missing.

  • what have you tried so far to achieve this
    as a part of the process i tried following steps to get some results.

  1. prepare analysis on sonarqube
  2. npm install
  3. npm custom (run build – --prod)
  4. npm custom (test --code-coverage)
  5. publish code coverage
  6. publish test results
  7. run code analysis
  8. publish quality gate result

So can someone please help me to see if i have to add/modify/delete some steps to make it working.

Hi @v6prask,

The “Publish code coverage” task has nothing to do with SonarQube; it publishes your coverage report in Azure. Instead, you must make sure you correctly configure the “Run Code Analysis” task.

You can read more about Azure integration here (checkout Analysing other project types). You must make sure you point the sonar.javascript.lcov.reportPaths property to the coverage report generated by your test framework. You can read more about test coverage in SonarQube here.

1 Like