Software Development (CSC 321 2015F) : EBoards

CSC321.01 2015F, Class 06: Behavior-Driven Development


Overview

Preliminaries

Admin

Homework

Questions

Behavior-Driven Development

Key Features of BDD

Similarities between BDD and TDD

Differences between BDD and TDD

Should we replace TDD with BDD? (or vice versa)

    As a programmer
    I want the sqrt function to behave appropriately
    so that I can write valid code

    For example,

      When I give 4 an input to sqrt
      Then I expect to get 2 as an output
      When I give -4 as an input to sqrt
      Then I expect to get 0+2i as an output
      Wehn I give "frog" as an input to sqrt
      Then I expect to get an error message

    check_equal(2, sqrt(4));
    check_equal(imaginary(0,2), sqrt(-4));

Arguments for:

Arguments against:

Cucumber

Feature: search for movies by director

  As a movie buff
  So that I can find movies with my favorite director
  I want to include and search on director information in movies I enter
Background: movies in database

  Given the following movies exist:
  | title        | rating | director     | release_date |
  | Star Wars    | PG     | George Lucas |   1977-05-25 |
  | Blade Runner | PG     | Ridley Scott |   1982-06-25 |
  | Alien        | R      |              |   1979-05-25 |
  | THX-1138     | R      | George Lucas |   1971-03-11 |
Scenario: add director to existing movie
  When I go to the edit page for "Alien"
  And  I fill in "Director" with "Ridley Scott"
  And  I press "Update Movie Info"
  Then the director of "Alien" should be "Ridley Scott"
Scenario: find movie with same director
  Given I am on the details page for "Star Wars"
  When  I follow "Find Movies With Same Director"
  Then  I should be on the Similar Movies page for "Star Wars"
  And   I should see "THX-1138"
  But   I should not see "Blade Runner"

Scenario: can't find similar movies if we don't know director (sad path)
  Given I am on the details page for "Alien"
  Then  I should not see "Ridley Scott"
  When  I follow "Find Movies With Same Director"
  Then  I should be on the home page
  And   I should see "'Alien' has no director info"

Work Time