我刚刚为一个新项目添加了一些单元测试。通常我使用 @testable import
导入生产代码,以便测试非公开方法:
@testable import My-Project
import XCTest
final class MyTests: XCTestCase {
func testOne() {
// ...
}
}
然而,我看到一些奇怪的编译错误,这是我以前从未见过的:
Tests.swift:1:25: Consecutive statements on a line must be separated by ';'
Tests.swift:1:25: Expected expression after unary operator
Tests.swift:1:25: Expressions are not allowed at the top level
Tests.swift:1:18: No such module 'My'
我已经仔细检查了一遍又一遍,但还是无法弄清楚为什么会出现这个编译错误。
我错过了什么?