How to trigger Coverage badge and Test Coverage Visualization with cobertura coverage xml?

I’m trying to trigger proper coverage badge generation and test coverage visualization for one of my pet project.

This is my current config file.

I have successfully generated a Cobertura format xml for my coverage that stores in tests/_output/cobertura.xml. And I can also see my artifacts setting work there:

I’ve merged it into my main branch. Everything seems to work except the coverage badge is still
2022-01-15 23-27-51 的螢幕擷圖.

Also, the Cobertura xml file generated seems quite normal to me.

What did I miss?

@yookoala Thanks for the post and welcome to the forum!

I’m glad to see you got the text coverage visualization working!

To get the badge working you still need to setup parsing for the coverage value from the logs as described here in the documentation. Looking at your latest Merge Request adding ^\s*Lines:\s*\d+.\d+\% should work and then the badge will start to work once a pipeline has completed.

I hope this helps!

-James H, GitLab Product Manager, Verify:Pipeline Execution

Thanks! Did the following and the badge works:

  1. Added an extra grep to show the text coverage text without ANSI (I want colour for my test output).
  2. Add the coverage regex as mentioned.

Thanks for the help.

1 Like