Skip to content

Latest commit

 

History

History
31 lines (20 loc) · 1.9 KB

getting_setup.md

File metadata and controls

31 lines (20 loc) · 1.9 KB

Getting setup

We're pragmatic, so we use CocoaPods. It is a dependency manager for Cocoa projects, we're going to use it to pull in the required dependencies. If you're new to CocoaPods then read the extensive guides website to help you get started.

Adding a test Target

If you don't have a test target in your application then you need to add one. This can be done by opening Xcode, clicking File in the menu-bar then going to New > New Target. You'll find the test target under Other in iOS. It's called Cococa Touch Unit Testing Bundle. Adding this to your project will add the required bundle files, and you should choose to test (be hosted by) your existing application.

Setting up your Podfile

I'm presuming you already have a Podfile, if you don't consult the CocoaPods Getting Started guide. We're going to make changes to add testing tools. This means adding a new section in the Podfile. These typically look like the following:

target "App"
pod 'ORStackView'
[...]

target "AppTests" do
  inherit! :search_paths

  pod 'Specta'
  pod 'Expecta'
  pod 'FBSnapshotTestCase'
end

This links the testing Pods to only the test target. This inherits the app's CocoaPods (in this case ORStackView. ) CocoaPods will generate a second library for the testing pods Specta, Expecta and FBSnapshotTestCase. That is only linked to your Tests target.

You can test that everything is working well together by either going to Product > Test in the menu or by pressing ⌘ + u. This will compile your application, then run it and inject your testing bundle into the application.

If that doesn't happen, it's likely that your Scheme is not set up correctly. Go to Product > Scheme > Edit Scheme.. or press ⌘ + ⇧ + ,. Then make sure that you have a valid test target set up for that scheme.