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 created this task.Feb 13 2015, 8:07 AM
Krinkle raised the priority of this task from to Normal.
Krinkle updated the task description. (Show Details)
Krinkle added a subscriber: Krinkle.
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 13 2015, 8:07 AM
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
Krinkle removed a subscriber: Krinkle.Aug 14 2016, 5:39 AM
Krinkle moved this task from Inbox to PHPUnit on the MediaWiki-Core-Testing board.Jul 7 2017, 5:17 AM
kostajh added a subscriber: kostajh.

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

TK-999 added a subscriber: TK-999.Jun 1 2019, 2:33 PM

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! :)

TK-999 added a comment.EditedJun 2 2019, 10:55 AM

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

TK-999 added a comment.Jun 2 2019, 1:24 PM

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

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

Izno added a subscriber: Izno.Jul 2 2019, 1:12 PM
kostajh closed this task as Resolved.Jul 16 2019, 9:37 PM
kostajh claimed this task.

\o/

Congrats and well done!