开发者

XCode - Linking Tests with Sources without adding all source files to the Test Task

In Xcod开发者_开发技巧e, when source and test classes in are different folders - In the 'Test' task - how do you link against the source, as opposed to adding the all source files to the test task ?


The code under test has to be compiled and linked into either an executable or a library or framework. In the later case, just link your unit test bundle against the framework or library (whichever you are producing). In the case of an executbale, you can use bundle injection to inject your unit test bundle into the application at launch and run your unit tests. A tutorial for both scenarios is provided in the Xcode unit testing guide and a briefer overview here.

In short, for an application, set the test target's 'Test Host' property and 'Bundle Loader' property to '$(CONFIGURATION_BUILD_DIR)/MyApp.app/Contents/MacOS/MyApp'.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜