Provide command to adjust phpunit.xml for code coverage
authorKosta Harlan <kharlan@wikimedia.org>
Sun, 21 Jul 2019 18:34:23 +0000 (20:34 +0200)
committerKosta Harlan <kharlan@wikimedia.org>
Mon, 9 Sep 2019 12:32:02 +0000 (14:32 +0200)
Our current recommendation for adjusting PHPUnit configuration for
extension code coverage reports is to manually modify
tests/phpunit/suite.xml. This is cumbersome and annoying, since
suite.xml is version controlled.

This patch proposes a composer script to simplify editing
the (non-version controlled) phpunit.xml config in the root of the
MediaWiki repo. It is useful if you are interested in generating
code coverage reports based on unit tests only, not integration tests.

Usage: composer phpunit:coverage-edit -- extensions/GrowthExperiments

When you're done, you can run `rm phpunit.xml` to switch back to the
default phpunit.xml.dist.

The script will use the default includes/src/maintenance directories,
but a future improvement would be to identify the relevant directories
via the AutoloadClasses property of extension.json.

Another improvement would be to provide an option for passing
arbitrary paths in core, in case you are working on tests for a
specific class and want to generate coverage reports instantly.

We could probably also remove
dockerfiles/quibble-coverage/phpunit-suite-edit.py (which inspired
this patch) and use composer phpunit:coverage-edit instead.

Bug: T100294
Change-Id: Ia0ef41f67ca4a64b0d1ca0ddcee488c29630af0b


No differences found