[英]XCUITest: How to set a specific state when creating iOS UI Tests for an app using GraphQL?
I'm new to iOS development.我是 iOS 开发的新手。 My question is how can I send data to my API so that I can set a state in iOS.
我的问题是如何将数据发送到我的 API 以便我可以在 iOS 中设置状态。 For example if I have an app that can create and delete contacts.
例如,如果我有一个可以创建和删除联系人的应用程序。 How can I send data to the API so that if I want to test just deleting a contact when I launch the test a contact has already been created so that I can just test deleting it?
如何将数据发送到 API,以便如果我想在启动测试时仅删除联系人进行测试,则已经创建了一个联系人,以便我可以测试删除它? My app uses a GraphQL API.
我的应用程序使用 GraphQL API。 I tried calling the function that creates contacts by hardcoding the data needed and putting the function within a launch argument then using that launch argument in my test but that doesn't seem to work.
我尝试通过对所需数据进行硬编码并将该函数放在启动参数中,然后在我的测试中使用该启动参数来调用创建联系人的函数,但这似乎不起作用。 So I'm not sure if this is possible to do within xcuitest.
所以我不确定这是否可以在 xcuitest 中完成。 Any suggestions?
有什么建议么?
I think you can use mock services like open source wiremock我认为你可以使用像开源wiremock这样的模拟服务
Connect the app with wiremock and stub the data for API calls that you want to use :使用 wiremock 连接应用程序并存根要使用的 API 调用的数据:
http://wiremock.org/docs/stubbing/ http://wiremock.org/docs/stubbing/
You can send data to wiremock and wiremock return the same data when you want to use it您可以将数据发送到wiremock,并且当您想使用它时,wiremock 返回相同的数据
http://wiremock.org/docs/stateful-behaviour/ http://wiremock.org/docs/stateful-behaviour/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.