Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

BDD and Behave


Published on

Behavior Driven Development (BDD) in Python with Behave

Published in: Technology
  • Login to see the comments

BDD and Behave

  1. 1. Who Am I? Developer/Evangelist at LaunchKey Founder/Co-Organizer of Las Vegas PHP UG Co-Organizer of Las Vegas Developer UG #vegastech enthusiast Testanista
  2. 2. What is BDD? Behavior Driven Development is developing for required application behavior BDD utilizes tests who’s result are in a plain language understood by the business BDD uses Extreme Programming (XP) based features and scenarios to accomplish both goals
  3. 3. Why Use BDD? BDD tests all the things BDD only tests what matters BDD makes it easy to understand what’s not working BDD documents requirements in the system
  4. 4. What is Behave? Python implementation of the Cucumber specification Uses Gherkin as the Domain Specific Language (DSL) to allow for writing tests in plain language Uses decorators and regular expressions to match steps with underlying code base Allows for reusable step code
  5. 5. Example Gherkin Feature: Home Page Scenario: Login Link Given I am on the homepage When I click " Login" Then I will be on the "LaunchKey | Log in" page
  6. 6. Example Step from behave import * use_step_matcher("re") @when(u'(?P<ignore>I )go to "(?P<url>[^"]*)"') @given(u'(?P<ignore>I )am on "(?P<url>[^"]*)"') def step_impl_go_to(context, url, **args): import re if re.match('http(s?)://.+', url) is None: url = context.base_url + url context.browser.get(url)
  7. 7. Why Use BDD Document features Better requirements Know what is broken Know how to reproduce a failure Have confidence that your application works
  8. 8. Why Use Behave Generates skeleton step code Reusable steps without function knowledge Provides a clean context between scenarios Multiple verb support
  9. 9. behave @adam_englander #launchkey on #vegastech on