Skip to content

Add network mocking for end to end tests#9422

Merged
jkmassel merged 19 commits intodevelopfrom
feature/wiremock-mocking
May 9, 2019
Merged

Add network mocking for end to end tests#9422
jkmassel merged 19 commits intodevelopfrom
feature/wiremock-mocking

Conversation

@jtreanor
Copy link
Copy Markdown
Contributor

@jtreanor jtreanor commented Mar 15, 2019

This PR adds network mocking for all of our end-to-end (Espresso) tests, including screenshot tests.

  • This uses WireMock to power mocking the network requests. you can see the docs here.
  • WireMock just runs a small HTTP server on localhost:8080 which mimics the WP API. Request/response configuration is done with the JSON files. I hope to use the same JSON files to mock the iOS tests.
  • This URL is injected into FluxC in place of public-api.wordpress.com. Thanks @aforcier for implementing this.
  • Images are not currently mocked, and still come from the web. This was proving tricky and I didn't want to block on it any longer. I will follow up on this later.
  • There is a new subproject, WordPressMocks which contains all of the configuration and mock files for WireMock. We can make this a subtree later and share the mocks with iOS.

The diff is very big, but it should be not too difficult to review as it is mostly JSON files 😄 You can see it without the JSON files here for easier reviewing. Without the JSON files, this is the diff size 😄

27 files changed, 706 insertions(+), 80 deletions(-)

Still to do:

Once the above is completed, this will be ready for review.

I plan to move libs/mocks to a subtreed repo so the mocks defined here can be shared with iOS.

To test:

  1. To esnure you are not using live secrets, and everything is mocked: cp gradle.properties-example gradle.properties.
  2. Run ./gradlew WordPress:connectedVanillaDebugAndroidTest --stacktrace.
  3. All the tests should pass.

Update release notes:

  • If there are user facing changes, I have added an item to RELEASE-NOTES.txt.

@peril-wordpress-mobile
Copy link
Copy Markdown

peril-wordpress-mobile bot commented Mar 15, 2019

Warnings
⚠️ PR has more than 500 lines of code changing. Consider splitting into smaller PRs if possible.

Generated by 🚫 dangerJS

@jtreanor jtreanor force-pushed the feature/wiremock-mocking branch 2 times, most recently from 0a93936 to 34bdf32 Compare March 19, 2019 12:19
@jtreanor jtreanor modified the milestones: 12.1 ❄️, 12.2 Mar 29, 2019
@loremattei loremattei modified the milestones: 12.2 ❄️, 12.4 Apr 22, 2019
@jtreanor jtreanor force-pushed the feature/wiremock-mocking branch from 4e0f591 to 682df39 Compare May 3, 2019 14:24
@jtreanor jtreanor marked this pull request as ready for review May 3, 2019 14:28
@jtreanor jtreanor modified the milestones: 12.4, 12.5 May 3, 2019
@jtreanor jtreanor force-pushed the feature/wiremock-mocking branch from 682df39 to 6edc2e9 Compare May 3, 2019 14:32
@jtreanor jtreanor requested review from JavonDavis and jkmassel May 3, 2019 14:32
@jtreanor jtreanor force-pushed the feature/wiremock-mocking branch from 6edc2e9 to 8dbce8b Compare May 3, 2019 16:13
Copy link
Copy Markdown
Contributor

@jkmassel jkmassel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ The code for this all looks sensible
✅ The tests pass on CLI
✅ The tests pass from within Android Studio
:shipit:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants