Page MenuHomePhabricator

Make PHPUnit tests run without installing MediaWiki
Closed, ResolvedPublic

Description

This is a medium to long term perspective. Our unit tests should not require MediaWiki to be installed.

It may or may not need a database to connect to (though to a large degree that should be mocked). But that can be passed as command line arguments. Anything else should be constructed/injected by the test or mocked.

Event Timeline

Krinkle raised the priority of this task from to Medium.
Krinkle updated the task description. (Show Details)
Krinkle subscribed.
Krinkle renamed this task from Make PHPUnit tests runnable without installing MediaWiki (tracking) to Make PHPUnit tests run without installing MediaWiki (tracking).Mar 21 2015, 12:56 AM
Krinkle set Security to None.
Phabricator_maintenance renamed this task from Make PHPUnit tests run without installing MediaWiki (tracking) to Make PHPUnit tests run without installing MediaWiki.Aug 14 2016, 12:15 AM

I may work on this at the hackathon, help welcome!

I may work on this at the hackathon, help welcome!

Not sure how much of help I could be personally, but I could at least provide some cheering on this one!

dumping a reference here so I am able to find in the future
https://gerrit.wikimedia.org/r/#/c/mediawiki/core/+/511074/ (and the related commit in Wikibase https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/Wikibase/+/511076/ ) is some result of my lame attempt at the Prague Hackathon to get some PHPUnit tests of Wikibase running without loading MediaWiki. I've been doing this with the intention to try out parallelizing the unit test run, hoping for some speed improvements on multi-CPU machines.

All really hacky and not fully functional, probably for really keen enthusiasts only.

Change 513106 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] [WIP/PoC]: Separate MediaWiki unit and integration tests

https://gerrit.wikimedia.org/r/513106

This should be ready to move forward. I've updated the branch to split proper unit tests into their dedicated suite. 5301 unit tests can now be run from your IDE in less than 5 seconds! :)

Yes, I've synced with Amir and based my work off of his :) So he's aware too

Here's what integration with Intellij's PHPUnit execution and coverage display looks like:

Screenshot 2019-06-02 at 15.18.54.png (1×2 px, 522 KB)

Change 513106 merged by Jforrester:
[mediawiki/core@master] Separate MediaWiki unit and integration tests

https://gerrit.wikimedia.org/r/513106

Change 517550 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] Introduce separate unit tests PHPUnit configuration

https://gerrit.wikimedia.org/r/517550

Change 517550 merged by jenkins-bot:
[mediawiki/core@master] Introduce separate unit tests PHPUnit configuration

https://gerrit.wikimedia.org/r/517550

Change 517701 had a related patch set uploaded (by TK-999; owner: TK-999):
[mediawiki/core@master] Move trivially compatible tests to the unit tests suite

https://gerrit.wikimedia.org/r/517701

Change 519165 had a related patch set uploaded (by Kosta Harlan; owner: Kosta Harlan):
[mediawiki/core@master] Unit tests: prevent access to global functions and variables

https://gerrit.wikimedia.org/r/519165

Change 519165 merged by jenkins-bot:
[mediawiki/core@master] Define unit and integration test suites

https://gerrit.wikimedia.org/r/519165

Change 517701 merged by jenkins-bot:
[mediawiki/core@master] Move trivially compatible tests to the unit tests suite

https://gerrit.wikimedia.org/r/517701

kostajh claimed this task.

\o/