Unit testing with third party libraries and Carthage

与世无争的帅哥 提交于 2020-01-06 03:26:36

问题


What is the proper way to use Carthage for dependency management, but also be able to write tests with it for types it pulls in. For example, (this is hypothetical) if I pull in AlamoFire and let’s say it has a Response protocol and different concrete types conform to the Response protocol. In my own library, if I were to do

   @testable import AlamoFire 

it would complain that Module ‘AlamoFire’ was not compiled for testing. Doing some research, I believe it’s because enable testability should be set to NO on release builds, which Carthage uses by default. Is there a way to use third party types like this in your test target?


回答1:


Use import instead of @testable import to access a module's public types.

Also in your test target's Build Phases, add AlamoFire to "Link Binary With Libraries"



来源:https://stackoverflow.com/questions/48388957/unit-testing-with-third-party-libraries-and-carthage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!