简体   繁体   English

XCUITest:如何在使用 GraphQL 为应用程序创建 iOS UI 测试时设置特定状态?

[英]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.

相关问题 iOS XCUITest - 如何使用 xcuitest 从应用切换器中删除应用? - iOS XCUITest - How to remove an app from the app switcher using xcuitest? 我可以将XCUITest与Swift一起用于使用Objective C开发的iOS应用程序的UI自动化吗 - Can i use XCUITest with swift for UI Automation for an iOS app which is developed using Objective C 如何使用 XCUItest 设置 UserDefaults - How to set UserDefaults with XCUItest 使用节点appium-xcuitest-driver测试ios应用 - Using node appium-xcuitest-driver to test ios app 如何从XCUItest类中设置可在应用程序委托中访问的参数 - How to set arguments from XCUItest class that are accessible in app delegate 如何使用 XCUITest 测试 UIImageView 是否包含具有特定名称的图像? - How to test if a UIImageView contains an image with a specific name using XCUITest? XCUITest:如何跳转到应用程序代码? 如何修改被测应用的状态? - XCUITest: How to jump into app code? How to modify the state of the app under test? XCUITest 集在 macOS 和 iOS 上运行 - XCUITest set running on both macOS and iOS iOS UI测试iMessage应用程序/扩展 - iOS UI Tests iMessage App/Extension 如何在 XCUITest 中访问 iOS 14 时间选择器 - How to access the iOS 14 time picker in XCUITest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM