Automated Testing with GHUnit and KIF

60
Automated Testing with GHUnit and KIF Michele Titolo Sr. Mobile Engineer / Prolific Interactive @micheletitolo

description

This talk will explain how we can all write better code; one of the easiest ways to do this is through testing. We'll cover two popular open source frameworks, GHUnit and KIF, both of which can be automated with a CI like Jenkins.

Transcript of Automated Testing with GHUnit and KIF

Page 1: Automated Testing with GHUnit and KIF

Automated Testingwith GHUnit and KIF

Michele TitoloSr. Mobile Engineer / Prolific Interactive

@micheletitolo

Page 2: Automated Testing with GHUnit and KIF
Page 3: Automated Testing with GHUnit and KIF

Why test your code?

Page 4: Automated Testing with GHUnit and KIF
Page 5: Automated Testing with GHUnit and KIF
Page 6: Automated Testing with GHUnit and KIF
Page 7: Automated Testing with GHUnit and KIF

Types of Frameworks

Page 8: Automated Testing with GHUnit and KIF

Types of Frameworks

Page 9: Automated Testing with GHUnit and KIF

• Unit Testing

Types of Frameworks

Page 10: Automated Testing with GHUnit and KIF

• Unit Testing

• UI Testing

Types of Frameworks

Page 11: Automated Testing with GHUnit and KIF

Choosing Frameworks

Page 12: Automated Testing with GHUnit and KIF

Unit

Page 13: Automated Testing with GHUnit and KIF

Unit

Page 14: Automated Testing with GHUnit and KIF

• OCUnit/SenTestKit

Unit

Page 15: Automated Testing with GHUnit and KIF

• OCUnit/SenTestKit

• GHUnit

Unit

Page 16: Automated Testing with GHUnit and KIF

UI

Page 17: Automated Testing with GHUnit and KIF

UI

Page 18: Automated Testing with GHUnit and KIF

• UIAutomation

UI

Page 19: Automated Testing with GHUnit and KIF

• UIAutomation

• Frank

UI

Page 20: Automated Testing with GHUnit and KIF

• UIAutomation

• Frank

• KIF

UI

Page 21: Automated Testing with GHUnit and KIF
Page 22: Automated Testing with GHUnit and KIF

GHUnit

Page 23: Automated Testing with GHUnit and KIF

Demo

Page 24: Automated Testing with GHUnit and KIF

Setup

Page 25: Automated Testing with GHUnit and KIF

GHUnit has it’s own target

Page 26: Automated Testing with GHUnit and KIF

GHTestCase

Page 27: Automated Testing with GHUnit and KIF

Automation

Page 28: Automated Testing with GHUnit and KIF

Apple keeps breaking testing from CLI

Page 29: Automated Testing with GHUnit and KIF

JUnit test results

Page 30: Automated Testing with GHUnit and KIF

Gotchas

Page 31: Automated Testing with GHUnit and KIF

Vertical slices of functionality

Page 32: Automated Testing with GHUnit and KIF

Apple breaks things

Page 33: Automated Testing with GHUnit and KIF

UI Testing is difficult

Page 34: Automated Testing with GHUnit and KIF

KIF

Page 35: Automated Testing with GHUnit and KIF

Demo

Page 36: Automated Testing with GHUnit and KIF

Setup

Page 37: Automated Testing with GHUnit and KIF

KIF has it’s own target

Page 38: Automated Testing with GHUnit and KIF

KIFTestController

Page 39: Automated Testing with GHUnit and KIF

KIFTestScenario & KIFTestStep

Page 40: Automated Testing with GHUnit and KIF

Automation

Page 41: Automated Testing with GHUnit and KIF

ios-simhttps://github.com/phonegap/ios-sim

Page 42: Automated Testing with GHUnit and KIF

/usr/local/bin/ios-sim launch $APPFILE --family ipad > ! ! /tmp/KIF-ipad-$$.out 2>&1

Page 43: Automated Testing with GHUnit and KIF

Test Output

Page 44: Automated Testing with GHUnit and KIF

cp "`grep "JUNIT XML RESULTS AT " /tmp/KIF-ipad-$$.out | sed 's/.*JUNIT XML RESULTS AT //'`" 'test-reports/KIF-ipad-results.xml'

Page 45: Automated Testing with GHUnit and KIF
Page 46: Automated Testing with GHUnit and KIF
Page 47: Automated Testing with GHUnit and KIF

Gotchas

Page 48: Automated Testing with GHUnit and KIF

[scenario addStep:[KIFTestStep stepToWaitForTimeInterval:1 ! description:@"wait"]];

[scenario addStep:[KIFTestStep !! stepToWaitForViewWithAccessibilityLabel:@"Table"]];

Page 49: Automated Testing with GHUnit and KIF

[KIFTestScenario setDefaultStepsToSetUp:[KIFTestStep ! setupSteps]];

Page 50: Automated Testing with GHUnit and KIF

[scenario addStepsFromArray:[LoginTestStep ! stepsToLoginWithEmail:TEST_EMAIL ! password:TEST_PASSWORD]];

Page 51: Automated Testing with GHUnit and KIF

[scenario addStep:[KIFTestStep !! ! ! ! ! ! ! ! stepToScrollToItemWithAccessibilityLabel:@"Settings"]];

Page 52: Automated Testing with GHUnit and KIF
Page 53: Automated Testing with GHUnit and KIF

In Summary

Page 54: Automated Testing with GHUnit and KIF

Do tests help you write better code?

Page 55: Automated Testing with GHUnit and KIF

Do tests help you write better code?Yes.

Page 56: Automated Testing with GHUnit and KIF

Do writing tests add to dev time?

Page 57: Automated Testing with GHUnit and KIF

Do writing tests add to dev time?Yes.

Page 58: Automated Testing with GHUnit and KIF

Is testing worth the extra time?

Page 59: Automated Testing with GHUnit and KIF

Is testing worth the extra time?Absolutely.

Page 60: Automated Testing with GHUnit and KIF

The End

Michele Titolo@micheletitolo

https://github.com/mtitolo/UICatalog-Tests