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

Cucumber/Calabash on the Titanium platform

Ronald Treur
December 03, 2014

Cucumber/Calabash on the Titanium platform

Learn more about testing in general, the awesomeness that is Cucumber and how to use it yourself when developing your next Titanium application!

Originally presented during the December 2014 Dutch Titanium Meetup

Ronald Treur

December 03, 2014
Tweet

More Decks by Ronald Treur

Other Decks in Programming

Transcript

  1. Ronald Treur W H O A M I Freelance developer

    - Lost Particle Co-founder Snowciety (app) 3+ yrs Titanium experience Titan @ronaldtreur
 [email protected] github.com/RonaldTreur
  2. Unit Testing • Testing your software design • Tests isolated

    units of code and show correctness • Unit: smallest testable part of an application (often a single function/method or class) • Test cases are independent from each other • Each test represents a contract a unit must satisfy
  3. Behavior Driven Development (BDD) • Best practices used in TDD

    (coined by Dan North) • Tests are human readable, start with should and are NOT called tests (but behavior, or specifications) • (Unit) Testing frameworks that facilitate BDD:
 Jasmine, Mocha
  4. Acceptance Testing • Testing business logic & UI validation •

    Meant to verify completeness of a user story
  5. Testing flavors Unit testing makes sure you build the thing

    right Acceptance testing makes sure you build the right thing
  6. Cucumber • Test automation tool - Runs automated acceptance tests

    • Specification by example • Bridge gap between technical & non-technical team members (developers - stakeholders)
  7. Cucumber • Originally written in (and for) Ruby • Nowadays

    available for a various platforms, like Java, Javascript and C# • Available in over 40 languages (including Dutch)
  8. Outside-in Testing • Start with a failing Cucumber test •

    high level / functional (user story) • Write a failing Jasmine/Mocha test • low level / technical
  9. Gherkin • Your Cucumber feature files are structured using a

    syntax dubbed ‘Gherkin’ • Human readable specification language • BDD
  10. Example Feature: Sign up
 Sign up should be quick and

    friendly. 
 
 Scenario: Successful sign up
 New users should get a confirmation email and be greeted personally by the site once signed in. Given I have chosen to sign up
 When I sign up with valid details
 Then I should receive a confirmation email
 And I should see a personalized greeting message
  11. Calabash • Open source • Updated regularly • Created &

    maintained by Xamarin • iOS and Android support only
  12. Ti Calabash • Open source • Still in early stages

    • Created & maintained by Codexlabs & Appersonlabs • iOS and Android support only
  13. Installation npm -g ti-calabash ! Don’t install using sudo!* The

    installation will ask for your sudo-password during installation. If you use sudo yourself as well, this will fail.
 * See: http://howtonode.org/introduction-to-npm
  14. Execution Go to a folder containing a Titanium app ti

    calabash --platform=ios ti calabash --platform=android
  15. Execution • Asks you a few straightforward (hopefully) questions •

    Creates a features-folder in your project, with example features and everything needed to interpret them • Runs the example features and shows you the output • Saves (any) screenshots into your build-folder