使用 Quick 和 Nimble 進(jìn)行 Swift 單元測試

  1. 在單元測試的 Target -> General 勾選 Allow testing Host Application APIs
  2. 在 Podfile 中添加 Quick 和 Nimble
  3. 在 Podfile 中使用 use_frameworks! 或者 use_modular_headers! (單獨(dú)指定:modular_headers => true也可以)

忘記勾選 Allow testing Host Application APIs,在 import 第三方庫的時候會報以下錯誤:

Undefined symbols for architecture x86_64:
  "ObjectMapper.<- infix<A>(inout A, ObjectMapper.Map) -> ()", referenced from:
      DDBaseKitModule_Tests.TestModel.mapping(map: ObjectMapper.Map) -> () in DDModelTypeSpec.o
  "ObjectMapper.<- infix<A>(inout A?, ObjectMapper.Map) -> ()", referenced from:
      DDBaseKitModule_Tests.TestModel.mapping(map: ObjectMapper.Map) -> () in DDModelTypeSpec.o
  "(extension in DDBaseKitModule):Swift.Dictionary< where A == Swift.String>.queryStringParameters() -> Swift.String", referenced from:
      closure #1 () -> () in closure #1 () -> () in DDBaseKitModule_Tests.ExtensionSpec.spec() -> () in ExtensionSpec.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容