Code Coverage working example

Is there a working example of a repo with code coverage report?
The repository that is supposed to showcase this feature does not.
This is supposed to be a merge request with code coverage:

However, it does not show any.

The Code Coverage visualization feature does not seem to work in my private repo either.

Hmm, what do you exactly mean?

The visualization is there when you click on “Changes”:

The green line next to code marks line was covered by test. There is also a second MR where you can see the red line with code that was not hit by any test. Yes, it’s very subtle and perhaps hard to spot at first :slight_smile:

1 Like

I was expecting the coverage to show up also in the main branch, after the MR was merged
eg, here:

If one only commits test code, there is no way to see the coverage.

Perhaps I’m wrong, but I don’t think this is supported. As described by docs:

… you can collect the test coverage information of your favorite testing or coverage-analysis tool, and visualize this information inside the file diff view of your merge requests (MRs). This allows you to see which lines are covered by tests, and which lines still require coverage, before the MR is merged.

It does not say anything about just viewing file on a branch. I believe the feature was supposed to help maintaining existing code quality, so developers are aware how much code is tested before the merge (as that’s the usual workflow).

However, many coverage tools do have an option to export their results to e.g. html - so if you run the tests after merge (e.g. on main) and export them that way, you can download results and see the full test coverage locally. Also, there are some other 3rd party tools like SonarQube, that can import coverage results and show them in their UI for a specific branch.