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

Test Driving with RSpec and Cucumber

Test Driving with RSpec and Cucumber

Talked given to NYU Hackdays aimed at demonstrating the principles of BDD/TDD to early programmers. Demos at: https://github.com/ledwards/HackdaysTDD

Lee Edwards

April 02, 2012
Tweet

More Decks by Lee Edwards

Other Decks in Programming

Transcript

  1. Test-Driven Development Write a test Watch it fail Write the

    code Watch it pass Refactor, Refactor! RED GREEN REFACTOR Monday, April 2, 12
  2. Unit tests vs. Integration tests •Unit tests cover isolated behaviors

    •Integration tests cover full features •Unit tests mock or stub interfaces •Integration tests validate interfaces Monday, April 2, 12
  3. Cucumber •High-level integration testing for web applications •Uses a web

    browser driver or a web browser simulator •Natural language steps with custom definitions Monday, April 2, 12
  4. Advanced TDD • Mocking and stubbing • let statements •

    Factories and Fixtures Monday, April 2, 12
  5. How to Learn More • Use it on your projects

    • Contribute to Open Source • Read a book • Get an internship at a company that TDDs Monday, April 2, 12
  6. Reading • Test-Driven Development By Example by Kent Beck •

    Growing Object-Oriented Software, Guided By Tests by Steve Freeman • Refactoring by Martin Fowler • The RSpec Book by David Chelimsky Monday, April 2, 12
  7. Setting up Rails BDD • Add to Gemfile: • rspec-rails

    • cucumber-rails • jasmine • bundle install • rake db:test:prepare • rails g cucumber:install • rails g rspec:install • jasmine init Monday, April 2, 12
  8. Unit Testing • Ruby RSpec, Test::Unit • Python PyUnit, unittest

    • Java JUnit • Javascript Jasmine • iOS OCUnit, Cedar • Android Robolectric Monday, April 2, 12
  9. Integration Testing • Rails Cucumber, Steak, RSpec • Django SeleniumRC

    • Android Robotium • iOS Frank, iCuke, KIF Monday, April 2, 12