[wp-trac] [WordPress Trac] #63914: Reassess the need for the external-http tests
WordPress Trac
noreply at wordpress.org
Wed Sep 3 00:21:01 UTC 2025
#63914: Reassess the need for the external-http tests
------------------------------+-----------------------------
Reporter: johnbillion | Owner: (none)
Type: task (blessed) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Build/Test Tools | Version:
Severity: normal | Keywords:
Focuses: |
------------------------------+-----------------------------
Tests in the `external-http` group are flakey because they rely on actual
network requests over HTTP. There's no mocking in place. Server errors
(HTTP 5XX) and more recently an increase in the frequency of HTTP 429
responses from wordpress.org will cause the tests to fail.
Let's reassess the tests in this group and question exactly what it is
that each test is asserting.
As an example, the `Tests_HTTP_Functions::test_head_404()` test performs a
HEAD request to a non-existent URL and then verifies that the response is
not a `WP_Error` and that the response code is `404`.
What ''exactly'' is this verifying though?
* If it's verifying the correct population of the HTTP response code then
that should be handled by test coverage on `WP_HTTP_Requests_Response` and
a mocked up `\WpOrg\Requests\Response` instance. No need to perform a real
HTTP request.
* If it's verifying specifically that a 404 response doesn't result in a
`WP_Error` instance being returned by `wp_remote_*()` then can we do that
without performing an actual HTTP request? It should be possible with a
test-only transport class which returns a mocked raw HTTP response.
Of course we need to be careful not to remove or reduce coverage where
it's needed, but I'm positive we can remove many of the actual HTTP
requests from these tests (and move them out of the `external-http`
group).
--
Ticket URL: <https://core.trac.wordpress.org/ticket/63914>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list