objective-c - 当我在 Xcode 6.3 中运行单元测试时,为什么构建失败?

标签 objective-c xcode swift xcode6

当我尝试在 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.
    }
}

}

enter image description here

我自己的 MBP 和我雇主提供的 MBP 都会发生这种情况。我不禁认为这与项目设置有关。

适用于 Objective-C 测试。

非常感谢任何帮助,我已经拔掉了仅存的一点头发。

最佳答案

您不小心添加了一个 OS X 测试用例(由于导入 Cocoa,您可以看到这一点)。有时会发生这种情况,因为 Xcode 选择了错误的源。

当您向项目添加测试时,请确保这些是 iOS 测试。

enter image description here

关于objective-c - 当我在 Xcode 6.3 中运行单元测试时,为什么构建失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30098450/

相关文章:

objective-c - NSView 覆盖的 NSWindow 调整大小控件

ios - UITableView insertRows 不锁定主线程

xcode - 在 Xcode 中确认退出

objective-c - OS X 在后台打开 URL 方案

ios - MVC 通信,从 Swift 中的模型类更新标签

swift - 将变量从 UIButton 传递到另一个函数

objective-c - 在 Objective-C 中实现纯虚方法

ios - 使用试飞时应用程序崩溃

ios - Xcode Instruments 8.3 显示设置按钮丢失

xcode - 如何在 macOS 应用程序中从应用程序注册服务?