没有主机应用程序的Xcode测试

问题描述 投票:0回答:1

我创建了我可以想象的最简单的项目。

我创建了要测试的功能:

func addition(_ number1: Int, _ number2: Int) -> Int {
    return number1 + number2
}

现在,我要在没有主机应用程序的情况下对此进行测试,因此我们不必启动模拟器即可进行测试。

我创建了一个新的测试文件“ TestableFunctionsTests.swift”,内容如下:

import XCTest
@testable import SimpleProject


class testFunctionsTests: XCTestCase {
    func testAddition() {
        XCTAssertEqual(addition(1, 2), 3)
    }

}

并取消选中主机应用程序

enter image description here

现在,当我尝试测试Command-U时,我的新测试无法运行!

我创建了一个存储库来帮助查看完整的“问题/错误信息”

https://github.com/stevencurtis/SimpleTestingProject.git

xcode
1个回答
0
投票

您遇到的问题是,您没有在TestableFunctionsTests.swift目标中包含SimpleProjectTests。为此,请确保在目标成员资格框内的文件检查器中选中了适当的框。

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.