加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

swift – 单元测试找不到类测试

发布时间:2020-12-14 05:52:43 所属栏目:百科 来源:网络整理
导读:我有一个股票标准类调用GeoRssParserDelegate需要测试。 在我的快速单元测试中,我得到了: func testParser(){ var bundle = NSBundle(forClass:GeoRssParserTest.classForKeyedArchiver()) var path = bundle.pathForResource("test",ofType: "xml") let d
我有一个股票标准类调用GeoRssParserDelegate需要测试。

在我的快速单元测试中,我得到了:

func testParser()
{
    var bundle = NSBundle(forClass:GeoRssParserTest.classForKeyedArchiver())
    var path = bundle.pathForResource("test",ofType: "xml")
    let data = NSData.dataWithContentsOfFile(path,options: NSDataReadingOptions.DataReadingMapped,error: nil)
    let xmlParser = NSXMLParser(data:data)
    let delegate = GeoRssParserDelegate() <-- Compiler fails here
    var bStatus = xmlParser.parse()
    XCTAssertTrue(bStatus,"Parse failed",file: __FILE__,line: __LINE__)        
}

编译器在上面突出显示的行失败。编译器错误是使用未解析的标识符GeorRssParserDelegate

该类确实存在并与产品本身一起构建。有什么特别要求吗?

您必须将应用程序的模块导入到单元测试中。这通常是你的应用程序名称。例如,如果您的应用程序名称是GeoRssParser,则import语句将是:
import GeoRssParser

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读