Recently the libraries I've been working on had broken @covers tags, but CI wouldn't complain about it until after the change was merged. It would be good to have a generic phpunit-coverage job that runs as part of test and gate-and-submit, but doesn't publish.
Can probably be attached to one of the subtasks of T100294: [EPIC] Encourage developers to increase code coverage
Assuming libraries have a fast test suite, it probably make sense to always run with coverage reporting?
Slightly related but not blocking:
A while ago we had a similar discussion with James Forrester T101544: Provide (pre-merge) code coverage reports on patchsets. But we would need some way to store the coverage reports and make them easily browseable (T101545).
This task is just about changing phpunit to run with --coverage for smaller repos like libraries. Similar to how we run JSDuck and Doxygen on various repos pre-merge. That way, a problem in it will be discovered and block merge (as it should). Instead of breaking the publish build post-merge (usually invisible to the user).
Can probably use --coverage-clover and make it browseable in Jenkins as well. That way it isn't just a boolean pass/fail to catch typos and syntax errors, but also helps encourage browse the report in Jenkins and verify whether some methods aren't covered for code reviewers without having to verify and re-run locally.
Automated regression detection and publishing of html-reports is lower priority and a separate task indeed.