[wp-trac] [WordPress Trac] #55652: Test tool and unit test improvements for 6.1

WordPress Trac noreply at wordpress.org
Mon Jun 20 19:35:13 UTC 2022

#55652: Test tool and unit test improvements for 6.1
 Reporter:  hellofromTonya            |       Owner:  (none)
     Type:  task (blessed)            |      Status:  new
 Priority:  normal                    |   Milestone:  6.1
Component:  Build/Test Tools          |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:

Comment (by SergeyBiryukov):

 In [changeset:"53537" 53537]:
 #!CommitTicketReference repository="" revision="53537"
 Tests: Refactor `Tests_Image_Functions::test_load_directory()` to split
 the tests and use a data provider.

 This one test was testing three different situations. When one assertion
 fails, the rest of the test would not be executed, so this leads to hiding
 one error behind another.

 Splitting the test into three distinct test methods still allows for
 testing each situation, but tests each one in isolation and won't hide

 The third part of the test, dealing with image editor engine classes, will
 also now use a data provider.

 Using a data provider has a number of advantages:
 1. If the first test case fails, it won't prevent the other test cases
 from being tested.
 2. The output from PHPUnit will be more descriptive in case of failure
 when using a data provider.
 3. Using named test cases in the data provider will also make the
 `--testdox` output much more descriptive and informative.

 The actual cases being tested, or the test itself have not been changed.

 * Adding `@covers` annotations.
 * Adding a failure message to each assertion when multiple assertions are
 used in the test.
 * Reusing an existing data provider with the available image editor engine

 Follow-up to [1061/tests], [53495], [53497], [53521], [53523], [53524],
 [53525], [53526], [53529], [53530], [53531].

 Props jrf.
 See #55652.

Ticket URL: <https://core.trac.wordpress.org/ticket/55652#comment:44>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform

More information about the wp-trac mailing list