Commit graph

12 commits

Author SHA1 Message Date
Lucas Werkmeister
0e93b2f8bd Remove misleading ** in phpunit.xml.dist
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
2021-02-26 18:03:09 +01:00
Umherirrender
a35ec7655f phpunit: fail on warnings
This includes phpunit warnings or deprecation notices

Change-Id: Ifea2312c0bf77f4cc2628401d8142efd2a53bc9c
2020-09-09 20:19:52 +02:00
James D. Forrester
194344a85b phpunit: Drop unused enforceTimeLimit command and related settings
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
2020-01-22 14:12:45 -08:00
Timo Tijhof
8373f51cb0 benchmarks: Exclude from PHPUnit test coverage
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
2019-12-18 01:24:42 +00:00
Max Semenik
4a17fd1202 Upgrade PHPUnit to version 7
Going directly to 8 is too much pain.

Depends-On: Iafcea151389663d79e70ad6ab3741ce8b2e25cac
Bug: T192167
Change-Id: I77ea560f4a5344bd1c356ecc3e7857968ad829b8
2019-11-20 21:02:33 -08:00
Amir Sarabadani
eddddc4f59 Discover unit tests in "Unit" directory
We now allow it but we don't discover them <insert scared emoji>

Follow up on I8cf6cd31f22d

Change-Id: I3888d92256d760ff29c85f6bd3137a7a64e0e791
2019-09-04 15:49:58 +02:00
Kosta Harlan
f5b008f521 Exclude extensions/skins test directories from coverage analysis
Follows-Up: I3d19627fa36f6cc6666c29fdb638272fdaa30630

Bug: T192078
Change-Id: I29dec891ee2327dde96dc293f3d9cda0e6a891fc
2019-07-17 12:06:42 -04:00
jenkins-bot
43914d3f43 Merge "Speed up code coverage generation for local development" 2019-07-11 19:05:14 +00:00
Kosta Harlan
9f865209d6 Speed up code coverage generation for local development
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
2019-07-09 11:14:23 -04:00
Kosta Harlan
fb3d83362c Reorganize testsuites
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
2019-07-07 21:26:34 -04:00
Kosta Harlan
1139a9af6a Unit tests: Support unit tests in extensions and skins
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
2019-07-01 16:21:01 -04:00
Kosta Harlan
214750d8d2 Define unit and integration test suites
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
2019-06-28 12:18:18 -04:00