Page MenuHomePhabricator

Reorganise tests in MediaWikiFarm to focus on unit tests
Open, LowestPublic


Currently a part of the tests (perhaps 15-30%) cover large parts of the general program, which make them more “integration tests” than “unit tests”. These tests and the corresponding tested code should be refactored such that it can be really tested with unit tests.

The aforementioned tests and tested code are mainly the code involving reading-writing-deleting-creating of files or involving global variables, which is:

  • ConfigurationTest
  • possibly ConstructionTest for the part reading superglobal variables
  • InstallationIndependantTest::testCreateLocalSettings
  • LoadingTest
  • MediaWikiFarmComposerScriptTest, particularly critical for this one, the tested code should be splitted in smaller parts
  • MediaWikiFarmScriptTest
  • MultiversionInstallationTest::testCacheExistence

In addition of a small refactoring in some parts, it can also be used the mocking feature of PHPUnit.

Event Timeline

Seb35 triaged this task as Medium priority.Apr 11 2017, 1:17 PM

The recent change (-; 6e59c1063fc3 to isolate the configuration in a specific class is one step in this direction (the so-called divide-and-test strategy :-).

Since I redacted this task, I have a less strong opinion about focusing on unit tests. Some thoughts:

  • ideally large parts should be splitted in smaller functions, and it will help create unit tests;
  • on the other side, integration tests are also interesting ; but they should be labelled as such, perhaps by creating a subdirectory /tests/integration next to /tests/phpunit (both could use PHPUnit, it would reduce the number of dependencies)
  • real integration tests could be: 1/ mock some MW parts and check an extension is really activated, or 2/ test scenarios like updating a config file, or 3/ transitionning from no-cache to cache to no-cache. If integration tests are added (and I now think it would be better), a separate task should be created about it.
  • I read the Wikipedia article about IEEE 829 - perhaps a bit overkill for such a small software as MediaWikiFarm but I find it interesting, perhaps I will invest the $153 to buy the standard but very unsure for now

In the meantime of all these different orientations, perhaps the current task should focus on small rewritting of the current tests, and split them when possible. Other tasks should be opened (or not) about refactoring the main code into smaller functions, and about create integration tests.

Seb35 lowered the priority of this task from Medium to Lowest.Aug 22 2017, 1:25 PM
Seb35 removed Seb35 as the assignee of this task.Sep 13 2017, 6:02 PM

Removed myself from this task, I’m not working actively on it for now.

I just fixed a bug where Composer extensions were no more loaded; possibly an integration test could have tested this behaviour and detected the bug.