我正试着用快速的语言编写一个REST Api类并测试它。我试图遵循:how to test asynchronous methods Swift中的方法,但我似乎遇到了一个问题。
客户/服务接口
import Foundation
protocol RestSearchProtocol {
func didRecieveResponse(results: NSDictionary)
}
public class RestInterface : NSObject {
// lots of code we don't care about ...
}客户端测试/重构接口测试
import UIKit
import XCTest
import Client
class RestInterfaceTests: XCTestCase, RestSearchProtocol {
// ... rest of the test file我收到一个未声明的类型错误。

有什么建议作为如何使这项工作吗?
顺便提一句,如果我把RestInterfaceTests类放在RestInterface.swift的末尾,它似乎找到了协议,但是XCTestCase现在还没有声明。
发布于 2014-10-27 18:18:12
我似乎缺少了公共标识符:
import Foundation
public protocol RestSearchProtocol {
func didRecieveResponse(results: NSDictionary)
}
public class RestInterface : NSObject {
// lots of code we don't care about ...
}解决了这个问题
发布于 2017-05-25 20:01:33
使用@testable import Client,您不再需要将您的类型设置为公共类型了!
https://stackoverflow.com/questions/26593827
复制相似问题