测试 public class 时使用未解析的标识符
Use of unresolved identifier when testing a public class
我无法将我的 class 单元化,因为 Xcode 没有看到我的主要 class 测试目标。
我的swift模块定义为public
public class Geohash {
public static func encodeGeoHash(latitude: Double, longitude: Double, precision: Int = 12) -> String {
但是在我的测试目标下我看不到符号,
class GeohashTests: XCTestCase {
func testEncode() {
Geohash // /Users/maximveksler/Developer/GeohashKit/GeohashKitTests/GeohashTests.swift:13:9: Use of unresolved identifier 'Geohash'
}
}
我的测试目标不包括Geohash.swift
项目在https://github.com/maximveksler/GeohashKit/blob/master/GeohashKitTests/GeohashTests.swift#L13
在您的测试文件中添加以下行:
import GeohashKit
项目的测试部分是单独的模块,因此您需要导入应用程序模块来测试 class 文件,以便访问其 classes。
我无法将我的 class 单元化,因为 Xcode 没有看到我的主要 class 测试目标。
我的swift模块定义为public
public class Geohash {
public static func encodeGeoHash(latitude: Double, longitude: Double, precision: Int = 12) -> String {
但是在我的测试目标下我看不到符号,
class GeohashTests: XCTestCase {
func testEncode() {
Geohash // /Users/maximveksler/Developer/GeohashKit/GeohashKitTests/GeohashTests.swift:13:9: Use of unresolved identifier 'Geohash'
}
}
我的测试目标不包括Geohash.swift
项目在https://github.com/maximveksler/GeohashKit/blob/master/GeohashKitTests/GeohashTests.swift#L13
在您的测试文件中添加以下行:
import GeohashKit
项目的测试部分是单独的模块,因此您需要导入应用程序模块来测试 class 文件,以便访问其 classes。