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

WordPress Trac noreply at wordpress.org
Mon Jun 20 17:27:32 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:"53536" 53536]:
 {{{
 #!CommitTicketReference repository="" revision="53536"
 Tests: Always include the error message in `assertNotWPError()` and
 `assertNotIXRError()`.

 Previously, in case of failure, `WP_UnitTestCase_Base::assertNotWPError()`
 displayed the actual error message from the passed `WP_Error` object, but
 only if the `$message` parameter was empty.

 This made the assertion less helpful, as the actual error message was lost
 in case there was a non-empty `$message` parameter passed to the method,
 as per the [https://make.wordpress.org/core/handbook/testing/automated-
 testing/writing-phpunit-tests/#using-assertions Writing PHP Tests]
 guidelines:
 > All PHPUnit assertions, as well as all WordPress custom assertions,
 allow for a `$message` parameter to be passed. This message will be
 displayed when the assertion fails and can help immensely when debugging a
 test. This parameter should always be used if more than one assertion is
 used in a test method.

 This commit ensures that the actual error message is always displayed, in
 addition to the passed `$message` parameter.

 The same applies to `WP_UnitTestCase_Base::assertNotIXRError()`.

 Follow-up to [34638], [40417].

 Props jrf, SergeyBiryukov.
 See #55652.
 }}}

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


More information about the wp-trac mailing list