1

This is my dahsboard from Bamboo related to Sonarqube: https://i.stack.imgur.com/FU7c9.jpg

The project build result page looks like this: https://i.stack.imgur.com/DRltU.jpg

So, I want enable somehow test coverage in Bamboo to see unit tests reports. I mention that we have local coverage for my angular project.

Can you help me with this?

2 Answers 2

8

You'll need to get the results into a format that SonarQube can interpret. Assuming you are using Jasmine/Karma this would be an LCOV format.

  1. Modify your build script to include the following line:

    ng test --code-coverage

  2. This should create a coverage folder in your angular project. However it will be in an html format. You'll also need to change the Karma runner so that it generates an lcov.info file:

    // karma.conf.js
    // ....
    coverageIstanbulReporter: {
       dir: require('path').join(__dirname, '../coverage'),
       reports: ['lcovonly'],
       fixWebpackSourcePaths: true
    },
    // ....
    
  3. Finally, Update the sonar-project.properties file with the following line so that SonarQube knows where to find the coverage:

    sonar.typescript.lcov.reportPaths=coverage/lcov/lcov.info
    
1
  • I get WARN: Could not resolve 10 file paths in [/mnt/ramdisk/agents/agent12/work/dbe8ad65d6f5738a/coverage/lcov.info], first unresolved path: src/app/app.component.html - not sure what is wrong here
    – Felix
    Jun 16, 2021 at 9:17
0

Are you outputting the results to some sort of file or trying to get the results from SonarQube directly?

Generally, the test results are published in Bamboo by adding a Test Parser task and pointing it to a supported test output file.

Atlassian does have some good articles around writing your own test collector and reporter though, so you probably could write a custom parser to report directly from SonarQube over their API.

3
  • I have a html output. imgur.com/a/gFuG3TL In Bamboo i want to have some statistics or something for this local coverage.
    – m1b
    Jun 13, 2019 at 13:37
  • Your best bet would be to see if you can output the results in JUnit format (xml) as Bamboo supports reporting on that out of the box and add the results parser. For example, jest and karma both have plugins for junit reporting. That will give you pass/fail results, stats around recently failed tests, timing, ect.
    – Mark
    Jun 13, 2019 at 13:56
  • I already have integrated in my build test results -> imgur.com/a/QR3PZib All I want now is to have something like on this page: yuriburger.net/2018/09/24/getting-coverage-reports-with-angular But here is integrated via sonarqube own app, not in bamboo
    – m1b
    Jun 13, 2019 at 14:23

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.