简体   繁体   中英

XCUITest mock specific endpoints

I'm trying to achieve mocked responses for certain endpoints for UI testing in XCUITests. However all the available mock servers set the url at the start of the test and hence all the requests go through them.

How can I make only specific requests to go through the local mock server and rest of the requests to go through the default prod / stage endpoints?

checkout http://wiremock.org/ . There is proxy setting that allow you to redirect URL to actual end points v/s mock end point. Technical name is proxy stub mapping: http://wiremock.org/docs/proxying/

Copy And Paste from documents

Proxy stub mappings Proxy responses are defined in exactly the same manner as stubs, meaning that the same request matching criteria can be used.

The following code will proxy all GET requests made to http://:/other/service/.* to http://otherservice.com/approot , eg when running WireMock locally a request to http://localhost:8080/other/service/doc/123 would be forwarded to http://otherservice.com/approot/other/service/doc/123 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM