San Francisco

Teacher

Attendance

6 students were there

March 6, 2014

Behavior Driven Development with Cucumber

When you built your first few rails apps, there's a good chance that you started to think about them in terms of what resources you needed to create. For example, if you were creating a blog, you might have run `rails generate scaffold Post title:string content:text user:references`. While there's nothing wrong with this bottom-up approach, you probably spent some time on the command line reasoning about what fields you needed in your database, and why you needed those fields. Behavior Driven Development (BDD) allows us to start off by reasoning about what we're building and what it should do, so that when we do get to the point of creating models, views, and controllers, we'll know what we need to create without losing focus.

Feature: Attending RailsSchool

Scenario: Come in Person
Given I am in Charlottesville
And I'm at RailsSchool
And it's 5:30pm EST on March 6th
Then I will be learning about BDD

Scenario: Join the Hangout
Given it's 5:30pm EST on March 6th
And I'm logged into RailsSchool
And I visit the whiteboard for this lesson
Then I will see a google hangout link

Behavior Driven Development, also called outside-in development and specification by example is a process we use to communicate about what we're building in terms that should make sense to anyone close to the project (especially those who don't have development experience!).

Aslak Hellesøy created cucumber, a tool that facilitates this process. Using cucumber, we can write down what an application should do in the form of simple language and examples (like the above scenarios). Cucumber then lets us run these examples as tests, which can be used to:

  • Show that our app behaves the way we want it to, at least for the example cases
  • Guide our development by allowing us to focus on a single failing test at a time
  • Provide automated regression testing as the app becomes more complex
  • Communicate with others about what the app can do, or where it broke


2:30pm Pacific - 4:30pm Pacific on March 6, 2014 at Coshx Labs
6 students were there

Whiteboard

Please, sign in to see the Whiteboard