Page MenuHomePhabricator

[EPIC] Speed up unit test execution and increase code coverage
Closed, ResolvedPublic

Description

Documentation on wiki

https://mediawiki.org/wiki/Reading/Web/Projects/Invest_in_the_MobileFrontend_%26_MinervaNeue_frontend_architecture#Speed_up_unit_test_execution_and_increase_code_coverage

What

Tests are a crucial part in the development flow to verify that the code works as intended and is future-proof against changes of behavior. With the current stack tests take a long time to run (because of the ResourceLoader strain and the overhead of running through MediaWiki). As a result of the cost of running tests and the slow feedback cycle during the development flow, we haven’t kept up with properly testing the code, and this has negative effects on feature stability and resilience, and on confidence in changing the code.

Leveraging the Automatic bundling goal, we will follow the Extension:Popups approach and migrate as many unit tests as we easily can to run in the CLI (Node.js based). Tests that make extensive use of MediaWiki or are too tied to ResourceLoader will be considered integration tests and kept in mediawiki-qunit.

Untested files simple enough to test will have new tests added in the process of migration for Automatic bundling.

Progress

Progress can be measured by looking at the amount of files migrated to the src/ folder, like in the previous sub-project (automatic bundling), and the amount of test files moved or left from tests/qunit to tests/node-qunit.

Currently, we have low test coverage and are unable to accurately measure test coverage. Test coverage will be measured using istanbul as files are migrated to node-qunit and we’d aim for ~75% coverage.

Measuring progress of increasing code coverage

"speeding up unit test execution" gave us the power to measure code coverage from the command line. We can now monitor progress much more carefully by looking at overall code coverage. This is documented in:
https://www.mediawiki.org/wiki/Reading/Web/Projects/Invest_in_the_MobileFrontend_%26_MinervaNeue_frontend_architecture/Progress?useskin=vector#Goal:_Increasing_code_coverage

At the end of the project we will demonstrate which components were poorly tested but are no longer in

Evaluating success

We will measure which files are tested, and how long it takes to run the tests in the current setup (page load + text execution), and compare it with the files tested at the end, and the test execution time (cli run + test execution). We will compare both cold start, and “dev” mode (watching files to re-run tests as code changes).

We will be successful if we have more files tested, we are measuring test coverage, and the tests run faster.

We will monitor number of client side errors. As we add unit tests, we hope to see the number of errors decrease as we close out edge cases.

AC

  • We have a measure before the project starts about how many files are tested, and how many tests are run, and how long they take to run in some specific machine (we’ll have to use the same machine at the end of the project to measure the new setup)
  • A node.js qunit script is added to the npm scripts under test:node (Using the qunit package either directly or via mw-node-qunit)
  • The node.js tests run on CI per commit via the npm test job
  • The existing browser qunit tests are migrated to tests/node-qunit (where it makes sense) and run under Node.js, using ES modules (see Extension:Popups)
  • There is a coverage npm script that when run generates test coverage reports
  • We have measured the new setup and compared the info with the old setup, and reported on success metrics

Related Objects

StatusSubtypeAssignedTask
ResolvedJdlrobson
ResolvedJdlrobson
ResolvedJdlrobson
ResolvedJdrewniak
Resolvedpmiazga
ResolvedJdlrobson
ResolvedNone
ResolvedNone
ResolvedJdlrobson
ResolvedJdrewniak
ResolvedJdlrobson
ResolvedNone
ResolvedNone
Resolvedphuedx
ResolvedJdlrobson
ResolvedJdrewniak
ResolvedJdlrobson
DeclinedNone
ResolvedJdlrobson
DeclinedNone
DeclinedNone
DuplicateSpikeNone
DeclinedNone
ResolvedKrinkle
Resolvedovasileva
ResolvedJdlrobson
OpenNone
ResolvedNone
ResolvedNone
Resolved Niedzielski
Resolvedovasileva
DeclinedJdlrobson
ResolvedBUG REPORTJdlrobson
Resolvedphuedx
ResolvedJdlrobson
Resolvedovasileva
DeclinedBUG REPORTJdlrobson
Resolved nray
DeclinedNone
ResolvedNone
ResolvedNone
ResolvedJdlrobson
ResolvedJdlrobson
OpenNone
ResolvedJdlrobson
ResolvedLucas_Werkmeister_WMDE
DuplicateNone
ResolvedLucas_Werkmeister_WMDE
ResolvedMichael
ResolvedMichael
OpenNone
ResolvedAnneT
OpenNone
ResolvedVolker_E
OpenNone
OpenNone
DeclinedNone
OpenNone
OpenNone
OpenNone
StalledNone
OpenNone
ResolvedAnneT
ResolvedStevenSun
DeclinedJdrewniak
Resolvedovasileva
DuplicateBUG REPORTNone
ResolvedCatrope
Resolvedovasileva
ResolvedBUG REPORTEdtadros
ResolvedBUG REPORTovasileva
In ProgressNone
Resolved EUdoh-WMF
Resolved ppelberg
DeclinedBUG REPORTNone
OpenNone
DuplicateNone
DeclinedNone
Resolvedpmiazga
ResolvedJdlrobson
DeclinedNone
ResolvedJdlrobson
ResolvedJdlrobson
DeclinedNone
Resolved Niedzielski
DuplicateReedy
Resolved Niedzielski
ResolvedJdlrobson
ResolvedJdlrobson
DuplicateNone
Resolvedpmiazga
Resolvedovasileva
Resolvedovasileva
Resolvedovasileva
Resolved Niedzielski
DeclinedNone
Resolved Niedzielski

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
ovasileva renamed this task from Speed up unit test execution and increase code coverage to [EPIC] Speed up unit test execution and increase code coverage.Jun 4 2018, 10:07 AM
Vvjjkkii renamed this task from [EPIC] Speed up unit test execution and increase code coverage to ddcaaaaaaa.Jul 1 2018, 1:08 AM
Vvjjkkii triaged this task as High priority.
Vvjjkkii updated the task description. (Show Details)
Vvjjkkii removed a subscriber: Aklapper.
CommunityTechBot renamed this task from ddcaaaaaaa to [EPIC] Speed up unit test execution and increase code coverage.Jul 2 2018, 3:52 PM
CommunityTechBot raised the priority of this task from High to Needs Triage.
CommunityTechBot updated the task description. (Show Details)
CommunityTechBot added a subscriber: Aklapper.

No subtasks remain! Time to check off the AC and close?

Nope. Very far away from resolving this one.
we have code coverage measuring now but we need to add test coverage for a bunch of things.

Will add some subtasks that are not associated.

Jdlrobson raised the priority of this task from High to Needs Triage.Feb 26 2019, 7:09 PM
Jdlrobson triaged this task as Medium priority.Mar 29 2019, 3:15 AM
Jdlrobson claimed this task.
Jdlrobson updated the task description. (Show Details)

Probably not helpful to keep this open. Code coverage should be increased naturally as part of the other goals, but the goal of speeding up test execution is complete so I'm just going to resolve this.