【问题标题】:Why does the build fail when I run unit tests in Xcode 6.3?为什么在 Xcode 6.3 中运行单元测试时构建失败?
【发布时间】:2015-05-07 10:30:37
【问题描述】:

当我尝试在 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 测试。

任何帮助将不胜感激,我已经把剩下的头发拔掉了。

【问题讨论】:

  • 是 iOS 还是 OS X 项目?
  • 这是一个 iOS 项目。奇怪的是,我刚刚创建了一个空白的 iOS 项目,空白单元测试一切正常。所以我会重新创建我的项目,看看是否可行。

标签: objective-c xcode swift xcode6


【解决方案1】:

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

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

【讨论】:

  • 谢谢!!那做得很好:)
猜你喜欢
  • 2010-11-28
  • 1970-01-01
  • 2019-04-15
  • 2016-07-05
  • 2015-01-27
  • 2015-06-24
  • 1970-01-01
  • 2015-06-16
  • 1970-01-01
相关资源
最近更新 更多