SlideShare uma empresa Scribd logo
1 de 15
Behavior Driven Development by Mark Menard Vita Rara, Inc.
Test Driven Development ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
xUnit Testing ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
JUnit Test Example @ Test   public   void  simpleAdd() { Money  m12CHF =   new   Money ( 12 ,  "CHF" );  Money  m14CHF =   new   Money ( 14 ,  "CHF" );  Money  expected =   new   Money ( 26 ,  "CHF" );  Money  result =  m12CHF . add(m14CHF);  assertTrue(expected . equals(result)); }
JUnit Test Fixture Setup public   class  MoneyTest {  private   Money  f12CHF;  private   Money  f14CHF;  private   Money  f28USD;  @Before   public   void   setUp () {  f12CHF =   new   Money ( 12 ,  "CHF" );  f14CHF =   new   Money ( 14 ,  "CHF" );  f28USD =   new   Money ( 28 ,  "USD" );  } }
Behavior Driven Development ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
My BDD Tool Kit ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Cucumber ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Cucumber Example Feature: Contact Us As an anonymous user I want to be able to send a message So that I can receive support or get an answer to a question Scenario: Load Form Given I am on "home page" When I follow "Contact Us" Then I should see "Please use the following form" Scenario: Submitting form Given I am on the "contact us page" When I fill in "contact_handler[email]" with "me@example.com" And I fill in "contact_handler[subject]" with "Help" And I fill in "contact_handler[body]" with "Content" And I press "send" Then I should see "Thanks for your message."
Why Cucumber? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
RSpec ,[object Object],[object Object],[object Object],[object Object],[object Object]
An RSpec Example You:  Describe an account when it is first created. Customer: It should have a balance of $0. describe Account, "when first created" do it "should have a balance of $0" do ... end end When you run this example, RSpec can provide a report like this: Account when first created - should have a balance of $0
Why RSpec? ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Mocha ,[object Object],[object Object],[object Object],[object Object],[object Object]
The Example Application ,[object Object]

Mais conteúdo relacionado

Mais procurados

Software Design
Software DesignSoftware Design
Software DesignSpy Seat
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder PresentationDoug Green
 
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)Joshua Warren
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponLaurent Duveau
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016CiaranMcNulty
 
The PHP Way Of TDD - Think First, Code Later
The PHP Way Of TDD - Think First, Code LaterThe PHP Way Of TDD - Think First, Code Later
The PHP Way Of TDD - Think First, Code LaterHiraq Citra M
 
Advanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan BroerseAdvanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan Broersedpc
 
Php tutorial
Php tutorialPhp tutorial
Php tutorialNiit
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it securityCESAR A. RUIZ C
 

Mais procurados (20)

Software Design
Software DesignSoftware Design
Software Design
 
Coder Presentation
Coder  PresentationCoder  Presentation
Coder Presentation
 
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
PHPSpec & Behat: Two Testing Tools That Write Code For You (#phptek edition)
 
Introduction to php exception and error management
Introduction to php  exception and error managementIntroduction to php  exception and error management
Introduction to php exception and error management
 
TypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret WeaponTypeScript: Angular's Secret Weapon
TypeScript: Angular's Secret Weapon
 
Csharp_Chap01
Csharp_Chap01Csharp_Chap01
Csharp_Chap01
 
Php
PhpPhp
Php
 
php_tizag_tutorial
php_tizag_tutorialphp_tizag_tutorial
php_tizag_tutorial
 
TDD, BDD, RSpec
TDD, BDD, RSpecTDD, BDD, RSpec
TDD, BDD, RSpec
 
Rspec
RspecRspec
Rspec
 
Clean Code
Clean CodeClean Code
Clean Code
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016TDD with PhpSpec - Lone Star PHP 2016
TDD with PhpSpec - Lone Star PHP 2016
 
The PHP Way Of TDD - Think First, Code Later
The PHP Way Of TDD - Think First, Code LaterThe PHP Way Of TDD - Think First, Code Later
The PHP Way Of TDD - Think First, Code Later
 
Advanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan BroerseAdvanced PHP: Design Patterns - Dennis-Jan Broerse
Advanced PHP: Design Patterns - Dennis-Jan Broerse
 
Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
Welcome to computer programmer 2
Welcome to computer programmer 2Welcome to computer programmer 2
Welcome to computer programmer 2
 
C plus plus for hackers it security
C plus plus for hackers it securityC plus plus for hackers it security
C plus plus for hackers it security
 
Cordovilla
CordovillaCordovilla
Cordovilla
 
PHP Lesson
PHP LessonPHP Lesson
PHP Lesson
 

Destaque

Beyond Testing: Specs and Behavior Driven Development
Beyond Testing: Specs and Behavior  Driven DevelopmentBeyond Testing: Specs and Behavior  Driven Development
Beyond Testing: Specs and Behavior Driven DevelopmentRabble .
 
Effective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven DevelopmentEffective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven DevelopmentAlexander Kress
 
Behavior Driven Testing for Multichannel Enterprise Applications
Behavior Driven Testing for Multichannel Enterprise ApplicationsBehavior Driven Testing for Multichannel Enterprise Applications
Behavior Driven Testing for Multichannel Enterprise ApplicationsBamdad Dashtban
 
Startup Institute: JS Testing & Behavior Driven Development
Startup Institute: JS Testing & Behavior Driven DevelopmentStartup Institute: JS Testing & Behavior Driven Development
Startup Institute: JS Testing & Behavior Driven DevelopmentConor Sheehan
 
Behavior Driven GUI Testing
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI TestingAmanda Burma
 
Behavior Driven Testing of Web Services
Behavior Driven Testing of Web ServicesBehavior Driven Testing of Web Services
Behavior Driven Testing of Web ServicesSurya Sreedevi Vedula
 
Behavior Driven Testing goes Mobile!
Behavior Driven Testing goes Mobile!Behavior Driven Testing goes Mobile!
Behavior Driven Testing goes Mobile!Thoughtworks
 
German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...Bastian Seehaus
 
Behavior driven development. Testing drupal using behat
Behavior driven development. Testing drupal using behatBehavior driven development. Testing drupal using behat
Behavior driven development. Testing drupal using behatAndrei Jechiu
 
Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)Anand Bagmar
 
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...FalafelSoftware
 
Behavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftBehavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftAspire Systems
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /CapybaraShraddhaSF
 
Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...Eric DeLabar
 
[Agile Testing Day] Behavior Driven Development (BDD)
[Agile Testing Day] Behavior Driven Development (BDD)[Agile Testing Day] Behavior Driven Development (BDD)
[Agile Testing Day] Behavior Driven Development (BDD)Cellenza
 

Destaque (20)

Calabash
CalabashCalabash
Calabash
 
Beyond Testing: Specs and Behavior Driven Development
Beyond Testing: Specs and Behavior  Driven DevelopmentBeyond Testing: Specs and Behavior  Driven Development
Beyond Testing: Specs and Behavior Driven Development
 
BDD training v5.0.1
BDD training  v5.0.1BDD training  v5.0.1
BDD training v5.0.1
 
Effective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven DevelopmentEffective Testing using Behavior-Driven Development
Effective Testing using Behavior-Driven Development
 
Behavior Driven Testing for Multichannel Enterprise Applications
Behavior Driven Testing for Multichannel Enterprise ApplicationsBehavior Driven Testing for Multichannel Enterprise Applications
Behavior Driven Testing for Multichannel Enterprise Applications
 
Startup Institute: JS Testing & Behavior Driven Development
Startup Institute: JS Testing & Behavior Driven DevelopmentStartup Institute: JS Testing & Behavior Driven Development
Startup Institute: JS Testing & Behavior Driven Development
 
Behavior Driven GUI Testing
Behavior Driven GUI TestingBehavior Driven GUI Testing
Behavior Driven GUI Testing
 
Behavior Driven Testing of Web Services
Behavior Driven Testing of Web ServicesBehavior Driven Testing of Web Services
Behavior Driven Testing of Web Services
 
Behavior Driven Testing goes Mobile!
Behavior Driven Testing goes Mobile!Behavior Driven Testing goes Mobile!
Behavior Driven Testing goes Mobile!
 
German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...German Testing Day 2015 - How behavior-driven development fuses developers an...
German Testing Day 2015 - How behavior-driven development fuses developers an...
 
Behavior driven development. Testing drupal using behat
Behavior driven development. Testing drupal using behatBehavior driven development. Testing drupal using behat
Behavior driven development. Testing drupal using behat
 
Behavior Driven Development
Behavior Driven DevelopmentBehavior Driven Development
Behavior Driven Development
 
Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)Building the "right" regression suite using Behavior Driven Testing (BDT)
Building the "right" regression suite using Behavior Driven Testing (BDT)
 
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
Unit Testing and Behavior Driven Testing with AngularJS - Jesse Liberty | Fal...
 
Behavior driven development
Behavior driven developmentBehavior driven development
Behavior driven development
 
Behavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shiftBehavior Driven Testing - A paradigm shift
Behavior Driven Testing - A paradigm shift
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /Capybara
 
Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...Natural Language UI Testing using Behavior Driven Development with Pavlov and...
Natural Language UI Testing using Behavior Driven Development with Pavlov and...
 
[Agile Testing Day] Behavior Driven Development (BDD)
[Agile Testing Day] Behavior Driven Development (BDD)[Agile Testing Day] Behavior Driven Development (BDD)
[Agile Testing Day] Behavior Driven Development (BDD)
 
Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)Behavior Driven Development Testing (BDD)
Behavior Driven Development Testing (BDD)
 

Semelhante a Behavior Driven Development with Rails

Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript TutorialDHTMLExtreme
 
Article 01 What Is Php
Article 01   What Is PhpArticle 01   What Is Php
Article 01 What Is Phpdrperl
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereLaurence Svekis ✔
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scriptsch samaram
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratiehcderaad
 
Introjs10.5.17SD
Introjs10.5.17SDIntrojs10.5.17SD
Introjs10.5.17SDThinkful
 
Javascript
JavascriptJavascript
JavascriptIblesoft
 
13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your codeSurendra kumar
 
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docxLabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docxDIPESH30
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsEugene Andruszczenko
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryRefresh Events
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptdominion
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Manoj Ellappan
 
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09Pyxis Technologies
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)Chiew Carol
 

Semelhante a Behavior Driven Development with Rails (20)

Basic JavaScript Tutorial
Basic JavaScript TutorialBasic JavaScript Tutorial
Basic JavaScript Tutorial
 
Javascript
JavascriptJavascript
Javascript
 
C# with Renas
C# with RenasC# with Renas
C# with Renas
 
Article 01 What Is Php
Article 01   What Is PhpArticle 01   What Is Php
Article 01 What Is Php
 
JavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript HereJavaScript Core fundamentals - Learn JavaScript Here
JavaScript Core fundamentals - Learn JavaScript Here
 
Tugas Pw [6]
Tugas Pw [6]Tugas Pw [6]
Tugas Pw [6]
 
Tugas Pw [6] (2)
Tugas Pw [6] (2)Tugas Pw [6] (2)
Tugas Pw [6] (2)
 
Basics java scripts
Basics java scriptsBasics java scripts
Basics java scripts
 
2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie2014 11 20 Drupal 7 -> 8 test migratie
2014 11 20 Drupal 7 -> 8 test migratie
 
Introjs10.5.17SD
Introjs10.5.17SDIntrojs10.5.17SD
Introjs10.5.17SD
 
Javascript
JavascriptJavascript
Javascript
 
13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your code
 
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docxLabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
LabsLab8.htmlLab 8 Im Thinking of a NumberBefore yo.docx
 
jQuery Presentation - Refresh Events
jQuery Presentation - Refresh EventsjQuery Presentation - Refresh Events
jQuery Presentation - Refresh Events
 
Eugene Andruszczenko: jQuery
Eugene Andruszczenko: jQueryEugene Andruszczenko: jQuery
Eugene Andruszczenko: jQuery
 
Advisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScriptAdvisor Jumpstart: JavaScript
Advisor Jumpstart: JavaScript
 
Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1Basic iOS Training with SWIFT - Part 1
Basic iOS Training with SWIFT - Part 1
 
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09
 
Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)React Native +Redux + ES6 (Updated)
React Native +Redux + ES6 (Updated)
 

Mais de Mark Menard

Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014Mark Menard
 
A Tour of Wyriki
A Tour of WyrikiA Tour of Wyriki
A Tour of WyrikiMark Menard
 
Small Code - RailsConf 2014
Small Code - RailsConf 2014Small Code - RailsConf 2014
Small Code - RailsConf 2014Mark Menard
 
Small Code - Ruby on Ales 2014
Small Code - Ruby on Ales 2014Small Code - Ruby on Ales 2014
Small Code - Ruby on Ales 2014Mark Menard
 
Write Small Things (Code)
Write Small Things (Code)Write Small Things (Code)
Write Small Things (Code)Mark Menard
 
JRuby 6 Years in Production
JRuby 6 Years in ProductionJRuby 6 Years in Production
JRuby 6 Years in ProductionMark Menard
 
Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013Mark Menard
 
Startup Lessons Learned
Startup Lessons LearnedStartup Lessons Learned
Startup Lessons LearnedMark Menard
 
Mobile Platforms and App Development
Mobile Platforms and App DevelopmentMobile Platforms and App Development
Mobile Platforms and App DevelopmentMark Menard
 
Ruby on Rails Training - Module 2
Ruby on Rails Training - Module 2Ruby on Rails Training - Module 2
Ruby on Rails Training - Module 2Mark Menard
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Mark Menard
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to RubyMark Menard
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecordMark Menard
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on RailsMark Menard
 
JRuby in a Java World
JRuby in a Java WorldJRuby in a Java World
JRuby in a Java WorldMark Menard
 

Mais de Mark Menard (15)

Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014Let's Do Some Upfront Design - WindyCityRails 2014
Let's Do Some Upfront Design - WindyCityRails 2014
 
A Tour of Wyriki
A Tour of WyrikiA Tour of Wyriki
A Tour of Wyriki
 
Small Code - RailsConf 2014
Small Code - RailsConf 2014Small Code - RailsConf 2014
Small Code - RailsConf 2014
 
Small Code - Ruby on Ales 2014
Small Code - Ruby on Ales 2014Small Code - Ruby on Ales 2014
Small Code - Ruby on Ales 2014
 
Write Small Things (Code)
Write Small Things (Code)Write Small Things (Code)
Write Small Things (Code)
 
JRuby 6 Years in Production
JRuby 6 Years in ProductionJRuby 6 Years in Production
JRuby 6 Years in Production
 
Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013Conference of Grand Masters Tech Talk 2013
Conference of Grand Masters Tech Talk 2013
 
Startup Lessons Learned
Startup Lessons LearnedStartup Lessons Learned
Startup Lessons Learned
 
Mobile Platforms and App Development
Mobile Platforms and App DevelopmentMobile Platforms and App Development
Mobile Platforms and App Development
 
Ruby on Rails Training - Module 2
Ruby on Rails Training - Module 2Ruby on Rails Training - Module 2
Ruby on Rails Training - Module 2
 
Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1Ruby on Rails Training - Module 1
Ruby on Rails Training - Module 1
 
Introduction to Ruby
Introduction to RubyIntroduction to Ruby
Introduction to Ruby
 
Intro to Rails ActiveRecord
Intro to Rails ActiveRecordIntro to Rails ActiveRecord
Intro to Rails ActiveRecord
 
Intro to Ruby on Rails
Intro to Ruby on RailsIntro to Ruby on Rails
Intro to Ruby on Rails
 
JRuby in a Java World
JRuby in a Java WorldJRuby in a Java World
JRuby in a Java World
 

Behavior Driven Development with Rails

  • 1. Behavior Driven Development by Mark Menard Vita Rara, Inc.
  • 2.
  • 3.
  • 4. JUnit Test Example @ Test public void simpleAdd() { Money m12CHF = new Money ( 12 , "CHF" ); Money m14CHF = new Money ( 14 , "CHF" ); Money expected = new Money ( 26 , "CHF" ); Money result = m12CHF . add(m14CHF); assertTrue(expected . equals(result)); }
  • 5. JUnit Test Fixture Setup public class MoneyTest { private Money f12CHF; private Money f14CHF; private Money f28USD; @Before public void setUp () { f12CHF = new Money ( 12 , "CHF" ); f14CHF = new Money ( 14 , "CHF" ); f28USD = new Money ( 28 , "USD" ); } }
  • 6.
  • 7.
  • 8.
  • 9. Cucumber Example Feature: Contact Us As an anonymous user I want to be able to send a message So that I can receive support or get an answer to a question Scenario: Load Form Given I am on "home page" When I follow "Contact Us" Then I should see "Please use the following form" Scenario: Submitting form Given I am on the "contact us page" When I fill in "contact_handler[email]" with "me@example.com" And I fill in "contact_handler[subject]" with "Help" And I fill in "contact_handler[body]" with "Content" And I press "send" Then I should see "Thanks for your message."
  • 10.
  • 11.
  • 12. An RSpec Example You: Describe an account when it is first created. Customer: It should have a balance of $0. describe Account, "when first created" do it "should have a balance of $0" do ... end end When you run this example, RSpec can provide a report like this: Account when first created - should have a balance of $0
  • 13.
  • 14.
  • 15.

Notas do Editor

  1. Show example_4_spec.rb