我Quick/Nimble
在我的应用程序中用于测试。这是我第一次做测试。我的应用程序中嵌入了三个 VC,navigationController
如下所示:
StoryBoard1(NAV -> VC1 -> VC2)->StoryBoard2(VC3).
我想分别测试每个viewController
意思,例如,当启动 VC3 的测试时,我不想启动 VC1,我需要测试直接进入 VC3 并测试它,记住 VC3 是分开的storyBoard
,它们所有人都在第一个共享一个资产净值storyBoard
。我试着这样做。
import XCTest
import Quick
import Nimble
@testable import MYApp
class VC3Tests: QuickSpec {
override func spec() {
var vc3: VC3!
var navigationController: UINavigationController!
beforeEach {
let storyBoard2 = UIStoryboard(name: "StoryBoard2", bundle: Bundle.main)
let storyBoard1 = UIStoryboard(name: "StoryBoard1", bundle: Bundle.main)
navigationController = storyBoard1.instantiateInitialViewController() as! UINavigationController
vc3 = storyBoard2.instantiateViewController(withIdentifier: NSStringFromClass(VC3.self)) as! VC3
navigationController.pushViewController(vc3, animated: false)
expect(navigationController.visibleViewController).toEventually(beAnInstanceOf(VC3.self),timeout: 3,pollInterval: 1)
_ = navigationController?.view
_ = vc3.view
}
}
}
但它不会推送到 VC3,并且在启动时它只会停留在 VC1 上。难道我做错了什么?