简体   繁体   English

XCUITest 模拟特定端点

[英]XCUITest mock specific endpoints

I'm trying to achieve mocked responses for certain endpoints for UI testing in XCUITests.我正在尝试为 XCUITests 中的 UI 测试的某些端点实现模拟响应。 However all the available mock servers set the url at the start of the test and hence all the requests go through them.然而,所有可用的模拟服务器在测试开始时都设置了 url,因此所有请求 go 都通过它们。

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?如何通过本地模拟服务器仅向 go 发出特定请求,并通过默认产品/阶段端点向 go 发出请求的 rest ?

checkout http://wiremock.org/ .结帐http://wiremock.org/ There is proxy setting that allow you to redirect URL to actual end points v/s mock end point.有代理设置允许您将 URL 重定向到实际端点 v/s 模拟端点。 Technical name is proxy stub mapping: http://wiremock.org/docs/proxying/技术名称是代理存根映射: 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 .以下代码将对 http://:/other/service/.* 发出的所有 GET 请求代理到http://otherservice.com/approot ,例如,在本地运行 WireMock 时,向 Z80791B3AE70002FAA88C246876 发出请求/service/doc/123 将被转发到http://otherservice.com/approot/other/service/doc/123

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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