Post on 08-May-2015
description
Automated Testingwith GHUnit and KIF
Michele TitoloSr. Mobile Engineer / Prolific Interactive
@micheletitolo
Why test your code?
Types of Frameworks
Types of Frameworks
• Unit Testing
Types of Frameworks
• Unit Testing
• UI Testing
Types of Frameworks
Choosing Frameworks
Unit
Unit
• OCUnit/SenTestKit
Unit
• OCUnit/SenTestKit
• GHUnit
Unit
UI
UI
• UIAutomation
UI
• UIAutomation
• Frank
UI
• UIAutomation
• Frank
• KIF
UI
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-simhttps://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
Michele Titolo@micheletitolo
https://github.com/mtitolo/UICatalog-Tests