PHPUnit parses the directory using the standard PHP glob() function; a
Bash-style “globstar” double asterisk, to match any number of
directories on a path, is not supported.
Change-Id: Iab408a4328e012777245227f5dfff40aaea27510
We don't currently use this flag, and if we were to start doing so, this
would make development impossible on Windows machines as php-invoker is
POSIX-only.
Bug: T243324
Change-Id: I114518ec626020945b948e355eff7fd204fa4ef3
Also move Benchmarker.php to maintenance/includes/ because
that file is not itself a benchmark, and that base class is
actually covered by tests and should remain included.
Change-Id: I4acd88242dde56a884d319dfc141a3511a8221a3
Going directly to 8 is too much pain.
Depends-On: Iafcea151389663d79e70ad6ab3741ce8b2e25cac
Bug: T192167
Change-Id: I77ea560f4a5344bd1c356ecc3e7857968ad829b8
Changing addUncoveredFilesFromWhitelist to false drastically speeds up code
coverage report generation. Including extensions/skins in the config also
removes the need to manually edit your phpunit.xml file when you want to inspect
code coverage for your extension or skin locally.
With this patch you can very quickly generate coverage for an extension/skin or
subsection of core, this is especially useful if you are using an IDE that
supports running a test and importing its coverage into the editor.
The downside to this patch is that the coverage report only contains
information about code that's exercised by the tests, so this patch on its own
is unsuitable for our current processes in integration/config which generate a
full code coverage report per patch for extensions or post-merge for core.
However, since we are not yet using phpunit.xml.dist in CI, this patch should be
OK to merge as is. A follow-up patch to integration/config will use sed or
phpunit-suite-edit.py to set processUncoveredFilesFromWhitelist to true.
Bug: T192078
Change-Id: I3d19627fa36f6cc6666c29fdb638272fdaa30630
The idea is that `vendor/bin/phpunit` could run all of the tests contained in
core + extensions + skins with no overlap, but that we can also provide
granularity for CI which wants to run some testsuites (e.g. core:unit and
core:integration) before extensions/skins, as well as running unit before
integration tests.
Bug: T87781
Change-Id: I2fb57f4a9a58ec7a4042d9cc1821cc484661a6b9
For now only extensions with skin/extension.json which follow PSR-4 are
supported.
DefaultSettings is loaded in bootstrap to work around errors when unit tests are
run followed by integration tests (e.g. `vendor/bin/phpunit`)
Usage:
- composer phpunit:unit will run all unit tests in core and any tests in
`{extensions/skins}/tests/phpunit/unit` which also extend
MediaWikiUnitTestCase, and which have an extension.json file
- Pass a specific directory to only run unit tests for a particular extension,
e.g. `composer phpunit:unit -- extensions/GrowthExperiments`
Bug: T226911
Change-Id: I237a9f82e4d1b05cf2f08b3e4bb7ffcd8d47111c
Following discussion in Ibb8175981092d7f41864e641cc3c118af70a5c76, this patch
proposes to further reduce the scope of what unit tests may access, by removing
the loading of DefaultSettings and GlobalFunctions.php. This also has the
implied effect of disabling the storage backend, as well as the global service
locator.
MediaWikiTestCase is renamed to MediaWikiIntegrationTestCase so it's scope and
purpose is more clear. Whether we still need to keep `@group Database`
annotation around is debatable, as it's unclear to me what the performance costs
are of implying database access for all tests which extend IntegrationTestCase.
As far as I can tell, `@group Database` is primarily used in CI to run faster
tests before slower ones, and with the new UnitTestCase the annotation seems
redundant.
To run all testsuites, use `composer phpunit`. Other composer scripts:
- `composer phpunit:unit` to run unit tests
- `composer phpunit:integration` to run integration tests
- `composer phpunit:coverage` to generate code coverage reports from unit
tests (requires XDebug).
Note that you can pass arguments to composer scripts with `--`, e.g. `composer
phpunit:integration --exclude-group Dump`.
Other changes:
- Rename bootstrap.php to bootstrap.maintenance.php so it's clear it's part of
the legacy PHPUnit-as-maintenance-class setup
- Create new bootstrap.php which loads the minimal configuration necessary for
the tests, and do additional setup in the run() method of the unit/integration
test case classes
- Move the unit-tests.xml file to phpunit.xml.dist in preparation for this being
the default test configuration
For a follow-up patch:
- Find unit/integration tests for extensions/skins
- Migrate other test suites from suite.xml
- Support running all tests via vendor/bin/phpunit
Bug: T84948
Bug: T89432
Bug: T87781
Change-Id: Ie717b0ecf4fcfd089d46248f14853c80b7ef4a76