gpt4 book ai didi

ios - 如何将我的 App 模块导入 MyAppUITests 文件?

转载 作者:IT王子 更新时间:2023-10-29 05:19:30 25 4
gpt4 key购买 nike

这是我的简单测试用例:

import XCTest
@testable import MyApp //it doesn't work

因为这个:

enter image description here

class TabBarControllerTests: XCTestCase {

override func setUp() {
super.setUp()

let defaults = NSUserDefaults.standardUserDefaults()
defaults.setObject([], forKey: DBTabBarOrderedIndexesKey) //key is undefined, because of lack of my app module
defaults.synchronize()

continueAfterFailure = false
XCUIApplication().launch()
}

func testIsOrderOfTabsSaved() {

XCUIApplication().tabBars.buttons["Catering"].tap()
//what next?
}
}

点击 UITabBarItem 后,我更改了 DBAppSettings.mode 的值,所以在这里我想访问我的 DBAppSettings.mode 属性来检查它是否真的被改变了。

我注意到有一件奇怪的事情,当我构建我的应用程序并检查构建的内容时,没有为我的 UITest 目标构建。重要吗?

enter image description here

最佳答案

这是 Apple 的回应:

UI tests execute differently from Unit tests - Unit tests run inside your application process so they can access your application code. UI tests execute in a separate process, outside your application, so they can simulate how the user interacts with the application. It’s not expected that you will be able to access your app class from a UI test.

关于ios - 如何将我的 App 模块导入 MyAppUITests 文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31769120/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com