TDD/BDD



if a function takes a boolean as parameter and does different things based on that maybe it should be two functions!
same set of arguments for a lot of methods? wrap them in a class!
reek in rails identifies some smelly pieces of code

BDD: validation vs verification
requirements written as short user stories
- lightweight description of how app used.

BDD concentrates on behavior of apps rather than implementation of app

User Story
    1-3 sentences, in everyday language
    written by/with customer

    suggested format: 3x5 cards   —> customer feels more intimate
        feature name (e.g. add a movie)
        as a (stake holder)
        so that ( I can achieve some goal)
        I want to do some task
    easy to reassrage prioritize

www.pivotaltracker.com/‎

    •   
keep points per hardness of tasks  (1-8)

keep track of speed of how long it would take based on past history. backlog, icebox (cold cases). product owner decides if it is done.

type of tasks
-features of direct value to customer
- chores: User Stories that are necessary, but provide no direct, obvious value to customer "
    • “Find out why test suite is so slow”" – No points"


SMART stories"
•  Specific "
•  Measurable"
  Achievable 

(ideally, implement in 
 1 iteration)"
•  Relevant
(“the 5 why’s”)"
•  Timeboxed
(know when to give up)"
------------------------

lo-fi UI: basic pen/paper schetxhes. to avoid     what i said but not what i want. –  Avoid WISBNWIW* UI?"     * What-I-Said-But-Not-What-I-Want



use perk chart to parallelize tasks

Fallasies
costumers confuse digital mockups with completed features
stick to pen/paper not photoshop something
story boards/sketches reduces confusion
don't write code befor emaking sure you need it. (validation)
delivering a story as done, when you have only done the "happy" path!!




User story: refers to single feature
• Feature: ≥1 scenarios that show different ways a feature is used
– Keywords Feature and Scenario 
 identify respective components
– Kept in .feature files
• Scenario: 3 - 8 steps that describe scenario
• Step definitions: Ruby code to test steps
Kept in X_controller.rb files

5 Step Keywords

1. Given steps represent state of world before event: preconditions
2. When steps represent event–  e.g., simulate user pushing a button
3. Then steps represent expected post conditions; check if true
4.  / 5. And & But extend previous step

 Need a test database to run app •  Then edit .features file to add features
Fake User to try Scenarios?
Tool that pretends to be user 
to follow scenarios of user story
•  Capybara simulates browser
– Can interact with app to 
 receive pages
– Parse the HTML
– Submit forms as a user would


-------------------------------------------------------------------------------DEMO

$ bundle exec rake db:migrate
$ bundle exec rake db:test:prepare

$ vim feature/AddMovie.feature
Feature: User can manually add movie

    Scenario: Add a movie
        Given I am on the RottenPotatoes home page
        When I follow "Add new movie"
        Then I should be on the Create New Movie page
        When I fill in "title" with "Men in Black"
        And I select "PG-13" from "Rating"
        And I press "Save Changes"
        Then I should be on the RottenPotatoes home page
        And I should see "Men in Black"

    Then I should be on the Create New Movie page    # features/step_definitions/web_steps.rb:230
      Can't find mapping from "the Create New Movie page" to a path.
      Now, go and add a mapping in /home/ubuntu/cs169/1x/rottenpotatoes_hw3/features/support/paths.rb (RuntimeError)
      ./features/support/paths.rb:31:in `rescue in path_to'
      ./features/support/paths.rb:26:in `/^(?:|I )should be on (.+)$/'
      features/AddMovie.feature:6:in `Then I should be on the Create New Movie page'
$ vim features/support/paths.rb                       add:
 when /^the Create New Movie page/ then '/movies/new'

Example adding a new functionality to a project












Comments