Automated Testing
with GHUnit and KIF
             Michele Titolo
Sr. Mobile Engineer / Prolific Interactive
            @micheletitolo
Why test your code?
Types of Frameworks
Types of Frameworks
Types of Frameworks

• Unit Testing
Types of Frameworks

• Unit Testing
• UI Testing
Choosing Frameworks
Unit
Unit
Unit


• OCUnit/SenTestKit
Unit


• OCUnit/SenTestKit
• GHUnit
UI
UI
UI

• UIAutomation
UI

• UIAutomation
• Frank
UI

• UIAutomation
• Frank
• KIF
GHUnit
Demo
Setup
GHUnit has it’s own target
GHTestCase
Automation
Apple keeps breaking testing from CLI
JUnit test results
Gotchas
Vertical slices of functionality
Apple breaks things
UI Testing is difficult
KIF
Demo
Setup
KIF has it’s own target
KIFTestController
KIFTestScenario & KIFTestStep
Automation
ios-sim
https://github.com/phonegap/ios-sim
/usr/local/bin/ios-sim launch $APPFILE --family ipad >
! ! /tmp/KIF-ipad-$$.out 2>&1
Test Output
cp "`grep "JUNIT XML RESULTS AT " /tmp/KIF-ipad-$$.out | sed
's/.*JUNIT XML RESULTS AT //'`" 'test-reports/KIF-ipad-
results.xml'
Gotchas
[scenario addStep:[KIFTestStep stepToWaitForTimeInterval:1
! description:@"wait"]];


[scenario addStep:[KIFTestStep !
! stepToWaitForViewWithAccessibilityLabel:@"Table"]];
[KIFTestScenario setDefaultStepsToSetUp:[KIFTestStep
! setupSteps]];
[scenario addStepsFromArray:[LoginTestStep
! stepsToLoginWithEmail:TEST_EMAIL
! password:TEST_PASSWORD]];
[scenario addStep:[KIFTestStep !! ! ! ! ! ! !
! stepToScrollToItemWithAccessibilityLabel:@"Settings"]];
In Summary
Do tests help you write
better code?
Do tests help you write
better code?
Yes.
Do writing tests add to
dev time?
Do writing tests add to
dev time?
Yes.
Is testing worth the
extra time?
Is testing worth the
extra time?
Absolutely.
The End
https://github.com/mtitolo/UICatalog-Tests




             Michele Titolo
             @micheletitolo

Automated Testing with GHUnit and KIF