[wp-trac] [WordPress Trac] #53431: Tests: Reset global $current_screen between tests to avoid cross-test interdependencies

WordPress Trac noreply at wordpress.org
Wed Jun 16 16:29:02 UTC 2021


#53431: Tests: Reset global $current_screen between tests to avoid cross-test
interdependencies
------------------------------+-----------------------------
 Reporter:  hellofromTonya    |      Owner:  (none)
     Type:  defect (bug)      |     Status:  new
 Priority:  normal            |  Milestone:  Awaiting Review
Component:  Build/Test Tools  |    Version:
 Severity:  normal            |   Keywords:
  Focuses:                    |
------------------------------+-----------------------------
 As discovered in #52607, the global state of `current_screen` is not being
 reset to a known and expected state between tests. Rather, it's left to
 the individual test that modifies the state to reset it.

 Why is this a problem?

 If the global state is not consistent when a test starts, it can have
 unexpected results such as:

 - unstable test(s) downstream
 - misleading information for a specific piece of functionality under test
 which could result in "fixing" a problem that doesn't exist in the
 codebase but instead is in the test suite
 - increased effort to debug where the state was changed
 - bad contributor experience

 Other problems:
 - Increases the amount of code in the test suite as each test has to
 handle setting the state and then resetting it when done
 - Inconsistencies in how resetting is done (i.e. in the implementation)
 - Inconsistencies in the state's value when resetting (see above for the
 problems this can cause)
 - Reset circuit not being reached when a test fails and the reset is after
 the failed assertion

 This ticket proposes to move the global resetting to the test framework's
 abstract base test case `WP_UnitTestCase_Base` and likely in its
 `tearDown` method.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/53431>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list