【发布时间】:2016-08-22 18:47:09
【问题描述】:
我正在实施单元测试。最初的项目是用 Objective-C 编写的。
我创建了一个用 Swift 编写的新测试目标。
如何在我的测试文件中调用实际应用的 Objective-C 类?
我已尝试执行以下操作。
@testable import MyModule
但是,这似乎只有在所有文件都在 Swift 中时才有效,但对我来说并非如此。
我在项目设置中尝试了其他一些方法,但是这些方法似乎都不起作用。
我是否遗漏了一些明显的东西?
class MyTests: XCTestCase {
override func setUp() {
super.setUp()
// Put setup code here. This method is called before the invocation of each test method in the class.
}
override func tearDown() {
// Put teardown code here. This method is called after the invocation of each test method in the class.
super.tearDown()
}
func testExample() {
let vc = HomeViewController() //this line is failing. How do I expose this view controller written in objective c?
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
}
}
【问题讨论】:
标签: objective-c swift unit-testing