@Legoktm Hm.. how does this relate to the MediaWikiCoversValidator trait we use in MediaWiki core. Would it make sense to use one or the other for both cases? E.g. we could publish it as a non-mediawiki specific library used in core and in libs. Or we could use the covers-validator lib in core as well.
They are just two different approaches that have different entrypoints. Underneath both are using the same method for determining whether a method is covered.
ockcyp/covers-validator runs externally, and requires having a sane PHPUnit entrypoint (suite.xml file) to be able to find the tests.
MediaWikiCoversValidator is a trait that runs along with the normal PHPUnit tests, and just requires being added to each test individually (usually through inheritance).
I initially tried to get ockcyp to work for MediaWiki, but ran into issues with our custom tests/phpunit/phpunit.php wrapper not playing nicely. Maybe if/when T90875: Convert tests/phpunit/phpunit.php entrypoint to plain PHPUnit with bootstrap file is done, we can use that tool instead.
MediaWikiCoversValidator is harder to use since you need to add the trait everywhere. In MediaWiki most tests cases extend from MediaWikiTestCase so it was pretty easy to do. For libraries that just use plain PHPUnit\Framework\TestCase I think using ockcyp will be easier overall.
I think we can probably librarize MediaWikiCoversValidator for other projects that have weird requirements like MediaWiki, but I don't think we should encourage its use in libraries that don't need it.