Upgrade to Pro — share decks privately, control downloads, hide ads and more …

iOS BDD Beatdown

iOS BDD Beatdown

Figuring out how to do BDD for iOS isn't exactly clear cut. There are a number of contenders for framework of choice for both the integration and unit layers. Even when you've figured out which framework, it's not always easy to figure out what parts of your application to test and why. You're in luck! I've spent the last 1.5 years doing all the hard work for you! I'll offer a comparison of the popular BDD frameworks so you can figure out what will work best for you. I'll also be going over how to effectively BDD iOS applications as well as looking at how to retrofit your application with tests to cover the application's high value paths.

Stephen Caudill

February 16, 2013
Tweet

More Decks by Stephen Caudill

Other Decks in Technology

Transcript

  1. iOS BDD Beatdown Stephen Caudill Ask the audience what their

    level of experience with BDD is Show of hands: if you know what BDD is. If you practice BDD. If you do it on iOS. BDD is an evolution on Test Driven Development that provides a specific shared vocabulary that bridges the divide between Business and Technology
  2. 2 Years of BDD on iOS Stephen Caudill I’m here

    to help you leverage my experience in your selection of a BDD framework
  3. • Run our specs atomically • Pend specs • Set

    expectations • Mocks/Doubles • Run our suite on devices • With a minimal amount of pain Stephen Caudill as developers we also need a suite of other tools
  4. TDD with BDD Language? Stephen Caudill Seems like an acceptable

    shim, let’s look at some of the offerings
  5. Ubiquitous Language Stephen Caudill Not so much... Note about “Ubiquitous

    Language” at the unit level... Terse external assertions lead to thinking at a low level... and I don’t know about you, but I constantly forget which order the expected and actual results should go in.
  6. Focused Test Runs Stephen Caudill No The closest you’ll come

    is having a duplicate OCUnit target and adding only the class you want to run to that
  7. Run tests on Device? Stephen Caudill No This is disappointing,

    given the “official” nature of the framework
  8. Documentation Stephen Caudill NO OFFICIAL DOCS! The closest you’ll get

    is the “sentesting macro reference” from apple. Googling specific cases is easy due to the sheer amount of people using it.
  9. Ease of Installation Stephen Caudill C- Readme says to download

    the framework (presumably prebuilt)... It doesn’t say where from though and googling didn’t help. You can make it yourself by cloning the repo, running make from the Project-iOS directory, then running a script in the Scripts directory... there is no documentation around this.
  10. Verdict Stephen Caudill Better than OCUnit Transitioning to this from

    OCUnit is a breeze! And lo, there was a pretty test runner.
  11. Ease of Installation Stephen Caudill A it's initially unclear what

    target to install to… this augments SenTestingKit though, so just add it to a new or existing SenTestingKit target
  12. Expectations Stephen Caudill No, but... http://github.com/jonreid/OCMockito Jon Reid (author of

    OCHamcrest) also wrote OCMockito, which handles expectations.
  13. Documentation Stephen Caudill Good! Readme calls out the important stuff,

    there are lots of tutorials and the API has full documentation.
  14. Ease of Installation Stephen Caudill A Cocoapods is the recommended

    manner of installation and it makes it a breeze!
  15. Expectations Stephen Caudill Bring Your Own http://github.com/petejkim/expecta Sister project called

    Expecta, from the same developer. Worth noting that Specta isn’t really useful without Expecta.
  16. Documentation Stephen Caudill Very little... It’s pretty much just the

    readme, but it identifies the most important aspects of the API.
  17. Ease of Installation Stephen Caudill B- - Using Kiwi 2,

    which is young - Install documentation is sparse - Cocoapods (pay attention to the output of pod install)
  18. Documentation Stephen Caudill As long as you don’t need to

    install it... http://kiwi-lib.info Kiwi 2 is new and documentation for it is pretty sparse Luckily most documentation for Kiwi 1 is still valid.
  19. Ease of Installation Stephen Caudill A+ Super easy! Between install

    script for the templates and the templates themselves, it's really painless.
  20. Stephen Caudill C++ ?!?! - So as we can see

    syntax is standardizing... - BUT! C++!?!? - Just because you can do something...
  21. Documentation Stephen Caudill In the form of a README in

    it’s defense, it’s a very good readme
  22. Ease of Installation Stephen Caudill A++ Would install again. Installation

    was very straightforward scripts work well and readme is accurate
  23. Ubiquitous Language Stephen Caudill Yes. Sir. - Ubiquitous language in

    the context of acceptance tests - Acts as an interpretation layer for Cucumber
  24. Verdict Stephen Caudill Very good. Autostarting the simulator is broken

    - passing `NO_LAUNCH=1 cucumber` will get around it, but you have to manually start/stop the simulator
  25. Ease of Installation Stephen Caudill A- If you have an

    OCUnit target, it’ll try to copy your octest socket (using Ruby) and fail as it’s an abnormal file type. Outside of that, the frank CLI and it’s subcommands make it easy to set things up
  26. Stephen Caudill This probably looks familiar (again) Tangent about web

    steps and the steps frank ships with - they’re difficult to remove
  27. Ease of Installation Stephen Caudill D KIF is a PITA

    to install. Cocoapods helps, but only if you cobble together the incantations from github issues and selectively ignore the README
  28. Stephen Caudill * only head works currently, due to changes

    in Xcode 4.5 (current version is 4.6) * ensure you specify the target for the pod
  29. Verdict Stephen Caudill Meh. Hard to set up Hard to

    learn No use of ubiquitous language But hey, it’s in objective C May be unfair to judge as an “acceptance” framework
  30. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C
  31. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C Only Use the TDD frameworks if you *have* to
  32. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C
  33. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C Because C++ is groooooss.
  34. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C Only Use the TDD frameworks if you *have* to
  35. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C
  36. Installation Ubiquitous Language Focused Tests Pending Tests Expectations Mocking Runs

    on Device Docs OCUnit GHUnit OCHamcrest Kiwi Cedar Specta/Expecta KIF Calabash Frank A+    N/A   D- C    N/A   C A    N/A   B B       C A+       B- A       B- D     N/A  D A+     N/A  A A-     N/A  C Automates with actual touch events