We see the coverage beign generated in our local machine dosent match with the coverage shown for the file in sonar.We are using codebuild where we run testcases and then get coverage.The coverage results are then sent to sonar.
We are using the below command in our buildspec.yaml file to send coverage results to sonar
Hi Colin, here’s a specific example I’m seeing. I have tests written for a file named map.ts and I can see full test coverage when running jest locally. But in SonarCloud it shows no test coverage. Thanks.
Is the report you’re showing a screenshot of being generated with local coverage information, or on AWS CodeBuild? I would suggest double checking the coverage file being produced on AWS CodeBuild to see if it matches locally.
Hi Colin, yes we’ve confirmed that the lcov files that are produced locally match the lcov files produced on AWS CodeBuild. But SonarCloud is still reporting no coverage for these methods. What do you recommend trying next?
Hi Colin we believe we’ve identified the issue. Our project has multiple folders which each have their own node project. We generate a coverage report for each folder and provide the list of lcov files as input to SonarCloud. So the parameters we’re actually passing to sonar-scanner are the following:
Is it possible for you to generate the absolute paths instead of the relative paths when generating the coverage reports (at least, enough of the path to let SonarCloud differentiate between them)? You’re right – for two coverage reports that both include shared/src/lib/map.ts, SonarCloud won’t be able to differentiate the files.