我实际上是尝试使用nimble-snapshot在我的应用程序中实现UI测试。我正面临着一个我不太懂的问题。我一直在环顾四周,但似乎没有找到我的问题的答案。
当我尝试实例化我的viewcontroller以尝试测试与之关联的视图时,我的问题就出现了。编译总是失败并显示此错误消息。
Undefined symbols for architecture x86_64:
"__T06medici19LoginViewControllerCMa", referenced from:
__T013mediciUITests13LoginViewTestC4specyyFyycfU_yycfU_ in
testUILogin.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我的测试代码如下所示:
import Nimble
import Nimble_Snapshots
import Quick
import UIKit
@testable import XXXXMyProject
class LoginViewTest: QuickSpec {
override func spec() {
describe("LoginView") {
var vcLogin: LoginViewController!
beforeEach {
let storyboard = UIStoryboard(name: "Account", bundle: nil)
vcLogin = storyboard.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
_ = vcLogin.view // To call viewDidLoad
}
it("has a valid snapshot") {
expect(vcLogin.view) == recordSnapshot()
}
}
}
}
作为UI测试的新手,我真的不明白是什么导致了这个问题。如何解决此问题或改进我的ui测试代码将非常感谢任何帮助或提示。
先感谢您。
马丁
UI测试无法使用您的应用程序内部。要测试它,请使用单元测试,但请确保选中单元测试目标>常规中的“允许测试主机应用程序API”选项。