Unit Tests fail, then don't

末鹿安然 提交于 2019-11-30 23:15:18

I took your fresh project and reproduced the problem. There are a number of issues, and one unknown:

Build Phases of test target:

  • Target Dependencies: Specify TestApp, so that the main target is always built first.
  • Compile Sources: Don't include any main sources. Only include TestAppUnitTests.mm
  • Link Binary With Libraries: The only one needed is SenTestingKit.framework. We can throw in Foundation and UIKit for good measure.
  • Copy Bundle Resources: Should have nothing. (Later, you may want test-specific resources.)

Build Settings of test target:

  • Bundle Loader should be $(BUILT_PRODUCTS_DIR)/TestApp.app/TestApp
  • Test Host should be $(BUNDLE_LOADER)

Scheme of main target:

  • Test -> Info should specify the test target

But even if I make all these changes, your project still has the odd behavior. The simulator sometimes gets a version of the app named, literally, ${PRODUCT_NAME}. Even debugging the app sometimes shows "Debug ${EXECUTABLE_NAME}" in the Log Navigator. So something else is awry, and I don't know what.

The best solution is to create a new project from scratch, specifying "Include Unit Tests". I've verified that this works.

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