TDD in iOS Development by examples Marko Čičak Igor Stojanović.

Post on 18-Jan-2016

242 views 0 download

Tags:

Transcript of TDD in iOS Development by examples Marko Čičak Igor Stojanović.

TDDin

iOSDevelopment

by examples

Marko ČičakIgor Stojanović

AGENDA1: TDD - how we started with

2: A full cup of TDD

3: Conclusion

4: Questions

TDD – HOW WE STARTED

- Java testing tools:

- JUnit

- TestNG

- Checkstyle

- FindBugs

- DbUnit

- Sonar

......

TDD – HOW WE STARTED

- Do you write tests for your iOS applications?

“The best testing is when I see how application works on my mobile device.”

MOBILE DEV. IS HARDComplex applications

MOBILE DEV. IS HARDLots of code

MOBILE DEV. IS HARDSmooth scrolling

MOBILE DEV. IS HARDOffline mode

MOBILE DEV. IS HARDState restoration

MOBILE DEV. IS HARD

MOBILE DEV. IS HARD

- Lots of code.

- No tests.

- Hard to develop and maintain.

- “It doesn’t work but it worked in previous versions.”

- Why didn’t you write tests?

“We didn’t have time”

TDD – HOW WE STARTEDNovember 2013 – CenterDevice iPhone client

- How to test?

- KIF, Frank, Appium, Zucchini, Calabash, UIAutomation...

- Guidelines:

Objective-C

Small learning curve

Easy to write and maintain

Fast execution

TDD – HOW WE STARTEDNovember 2013 – CenterDevice iPhone client

TDD – HOW WE STARTED

TDD

APP DEMO

TDD – NEW PROJECT

TDD – NEW PROJECT

TDD – NEW PROJECT

TDD – NEW PROJECT

TEST APP DELEGATE

TEST APP DELEGATE

TEST APP DELEGATE

TEST APP DELEGATE

TEST APP DELEGATE

TEST APP DELEGATE

SINGLETONS

SINGLETONS

SINGLETONS

SINGLETONS

XCTESTCASE

VIEW MODEL

VIEW MODEL

VIEW MODEL

VIEW MODEL

VIEW MODEL

CORE DATA

CORE DATA

CORE DATA

DATA PROVIDER

DATA PROVIDER

DATA PROVIDER

DATA PROVIDER

PROBLEM WITH ANIMATIONS

PROBLEM WITH ANIMATIONS

PROBLEM WITH ANIMATIONSWhat’s wrong with this code?

PROBLEM WITH ANIMATIONS

PROBLEM WITH ANIMATIONS

LOCALISATION

LOCALISATION

LOCALISATION

MODAL VIEWS

MODAL VIEWS

MODAL VIEWS

ALERT VIEWS

ALERT VIEWS

BENEFITS

- Early recognition if something is missing or not well specified.

- Tells you whether your last change or refactoring broke existing functionality.

- Prevents regression and future bugs

- New developer can figure out business logic through tests.

- Less time spent in debugging.

- Forces you to write small classes etc...

DISADVANTAGES

- It’s not trivial to learn because we didn’t used to write tests firsts.

- Could impact design.

- Code refactoring may impact tests.

- Can be short sighted.

OTHER TOOLS FOR TDD

- Expecta – XCTest extension

- OCMock – Helper for easier creation of stub objects

- Specta – TDD/BDD framework for Objective-C

- FBSnapshotTestCase – Snapshot view unit tests for iOS

- OCHamcrest - Hamcrest for Objective-C

- OCMockito

.....

CONCLUSIONTDD IS ONE MORE TOOL

IN YOUR DEVELOPER TOOLBOX

TESTING TOOLS

- KIF - https://github.com/kif-framework/KIF

- Zucchini - https://github.com/playup/zucchini

- Appium - http://appium.io

- Calabash - https://github.com/calabash/calabash-ios

- OCMock - http://ocmock.org

- Expecta - https://github.com/specta/expecta

- Specta - https://github.com/specta/specta

- FBSnapshotTestCase - https://github.com/facebook/ios-snapshot-test-case

- OCHamcrest - https://github.com/hamcrest/OCHamcrest

- OCMockito - https://github.com/jonreid/OCMockito

INTERESTING READ- Test-Driven iOS Developmet by Graham Lee

http://www.amazon.com/Test-Driven-iOS-Development-Developers-Library/dp/0321774183

- Test-Driven Development by Example by Kent Beck

http://www.amazon.com/Test-Driven-Development-By-Example/dp/0321146530

- Pseudo-Localization for Cocoa Apps – blog by Daniel Schneller

https://blog.codecentric.de/en/2013/10/pseudo-localization-cocoa-apps/

- Test-driven development - wikipedia

http://en.wikipedia.org/wiki/Test-driven_development

- Unit Testing Notification Observing on iOS – blog by Nikola Lajic

https://blog.codecentric.de/en/2014/09/unit-testing-notification-observing-ios/

QUESTIONS