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

Introduction to TDD and BDD

Introduction to TDD and BDD

Apresentação sobre as motivações sobre BDD e TDD feita no Café Ágil 2010 em BH - MG

danielvlopes

March 10, 2010
Tweet

More Decks by danielvlopes

Other Decks in Programming

Transcript

  1. def create(login, password, remember_me, auth_token) current_user = User.authenticate(login, password) if

    current_user.logged_in? if remember_me current_user.remember_me! cookies[:auth_token] = { :value => current_user.remember_token , :expires => current_user.remember_token_expires_at } end redirect_to home_page else redirect_to login_page end end
  2. Given I am on signup page When I fill email

    with “[email protected]” And fill password with “123456” Then I should see a success message
  3. # language: en Feature: Addition In order to avoid silly

    mistakes As a math idiot I want to be told the sum of two numbers Scenario Outline: Add two numbers Given I have entered 10 And I have entered 5 When I press add Then the result should be 15
  4. Before do @calc = Calculator.new end Given /I have entered

    (\d+)/ do |n| @calc.push n.to_i end When /I press (\w+)/ do |op| @result = @calc.send op end Then /the result should be (.*)/ do |result| @result.should == result.to_f end