wp2static icon indicating copy to clipboard operation
wp2static copied to clipboard

Mock external requests in sitemap tests

Open leonstafford opened this issue 4 years ago • 2 comments

As a developer I don't want to wait for slow network requests to run test suite So that I don't avoid running them frequently and they aren't susceptible to side effects

Currently, running composer test takes too long due to fetching external resources in the sitemap tests.

We should use local test data to simulate the responses we see from current external resources.

Sitemap test scope should at least cover:

  • dealing with valid sitemap responses
  • dealing with invalid sitemap responses
  • dealing with network errors (3xx, 4xx, 5xx)

leonstafford avatar Oct 12 '21 01:10 leonstafford

@palmiak suitable for Hacktoberfest?

leonstafford avatar Oct 12 '21 01:10 leonstafford

for now, running the sitemap external request tests fail on GH Actions runner due to access blockage.

we can mark tests with a group as "external requests" as per phpunit docs:

--exclude-group

Exclude tests from the specified group(s). A test can be tagged as belonging to a group using the @group annotation.

This will allow to keep running those locally, but skip on CI and optionally allow users to skip those slow external requests when testing locally, by passing same --exclude-group argument

leonstafford avatar Mar 20 '22 04:03 leonstafford