当我尝试在 Xcode 中为 Swift 项目运行默认单元测试时,构建会失败。
import Cocoa
import XCTest
class Test2: 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() {
// This is an example of a functional test case.
XCTAssert(true, "Pass")
}
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock() {
// Put the code you want to measure the time of here.
}
}
}
我自己的 MBP 和我雇主提供的 MBP 都会发生这种情况。我不禁认为这与项目设置有关。
适用于 Objective-C 测试。
非常感谢任何帮助,我已经拔掉了仅存的一点头发。
最佳答案
您不小心添加了一个 OS X 测试用例(由于导入 Cocoa
,您可以看到这一点)。有时会发生这种情况,因为 Xcode 选择了错误的源。
当您向项目添加测试时,请确保这些是 iOS 测试。
关于objective-c - 当我在 Xcode 6.3 中运行单元测试时,为什么构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30098450/