Getting “Test”-y
Test-driven Development & Automated Deployment for
                        iOS
Your Humble Speakers


• Jonah Williams - @Zalambar
• Rudy Jahchan - @rudy
How do we test?
How do we test?
         OCHamcrest
SenTestingKit       Cedar
              KIF
         GTM      Kiwi
          OCMock
                  Frank
       GHUnit
              iCuke
Why do we test?
Why do we test?

To make sure our code works
           (duh!)
Why do we test FIRST?
Why do we test FIRST?


   To design our code.
Why do we test FIRST?


   To design our code.
          (duh!)
Why do we test FIRST?
Test Structure
Test Structure

GIVEN
Test Structure

GIVEN
WHEN
Test Structure

GIVEN
WHEN
THEN
Test Structure

GIVEN   certain conditions
WHEN
THEN
Test Structure

GIVEN   certain conditions
WHEN    something happens
THEN
Test Structure

GIVEN   certain conditions
WHEN    something happens
THEN    the conditions change (or don’t)
Unit Testing
Unit Testing
Sample Class
xUnit Style
SenTestingKit
OCHamcrest
http://bit.ly/ochamcrest
Stubbing & Mocking
OCMock




http://bit.ly/qktX3H
GTM
http://bit.ly/gtmtest
GHUnit
http://gabriel.github.com/gh-unit/
BDD
BDD
Behavior
Driven
Design
RSpec




http://github.com/rspec/rspec
RSpec Book
Cedar




http://github.com/pivotal/cedar
Kiwi




http://kiwi-lib.info/
Integration Tests
Cucumber




http://cukes.info/
iCuke




http://github.com/unboxed/icuke
iCuke




http://github.com/unboxed/icuke
Frank




http://github.com/moredip/Frank
KIF
http://github.com/square/KIF
KIF
   Keep
   It
   Functional
http://github.com/square/KIF
KIF




http://github.com/square/KIF
Continuous Integration
Command-Line Builds
Command-Line
  Execution
➜ ~ ./build.sh
                                                     Bash
...
**** Describe Workspace
Available schemes
Information about workspace "My_App":
    Schemes:
        Ad Hoc
        Development
**** Set Environment
My_App/My_App/staging-Info.plist -> ~/TeamCity/build-agent-1/work/My_App_staging/My_App/My_App/My_App-Info.plist
My_App/My_App/staging.plist -> My_App/My_App/environment.plist
Environment set to com.MyCompany.My_App.staging at version 1.0
**** Increment Bundle Version
Setting version of project My_App to:
    24.
...
**** Build
Running xcodebuild > xcodebuild_output ...
...
Retrieving build products...
...
**** Package Application
Codesign as "iPhone Distribution: MyCompany, LLC", embedding provisioning profile ~/TeamCity/build-agent-1/work/My_App_staging/
ad_hoc/My_App_Staging_Ad_Hoc.mobileprovision
**** Verify
...
**** Prepare OTA Distribution
Generating com.MyCompany.My_App.staging.app.plist
**** Complete!




                             http://gist.github.com/949831
Rake




http://gist.github.com/1017153
Over The Air
Distribution
OTA: Roll Your Own
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>items</key>
  <array>
    <dict>
       <key>assets</key>
       <array>
         <dict>
           <key>kind</key><string>software-package</string>
           <key>url</key><string>$artifacts_url/$project_app.ipa</string>
         </dict>
         <dict>
           <key>kind</key><string>full-size-image</string>
           <key>needs-shine</key><true/>
           <key>url</key><string>$artifacts_url/$full_size_image_name</string>
         </dict>
         <dict>
           <key>kind</key><string>display-image</string>
           <key>needs-shine</key><true/>
           <key>url</key><string>$artifacts_url/$display_image_name</string>
         </dict>
       </array>
       <key>metadata</key>
       <dict>
         <key>bundle-identifier</key> <string>$bundle_identifier</string>
         <key>bundle-version</key><string>$short_version_string $build_number</string>
         <key>kind</key><string>software</string>
         <key>subtitle</key><string>$environment_name</string>
         <key>title</key><string>$project_app</string>
       </dict>
    </dict>
  </array>
</dict>
</plist>


       itms-services://?action=download-manifest&url=http://host.example/project_name.acceptance.app.plist
OTA: TestFlight




 http://testflightapp.com/
What’s Missing?
Factories
Factories
Fixtures
CoreData Migrations
Auto-testing
      guard integration
https://github.com/guard/guard

iOSDevCamp 2011 - Getting "Test"-y: Test Driven Development & Automated Deployment for iOS