BDD and Behave
-
Upload
adam-englander -
Category
Technology
-
view
68 -
download
0
Transcript of BDD and Behave
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
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
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
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
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
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 reif re.match('http(s?)://.+', url) is None:
url = context.base_url + urlcontext.browser.get(url)
Why Use BDD
Document features
Better requirements
Know what is broken
Know how to reproduce a failure
Have confidence that your application works
Why Use Behave
Generates skeleton step code
Reusable steps without function knowledge
Provides a clean context between scenarios
Multiple verb support
https://www.slideshare.net/AdamEnglander/bdd-and-
behave
http://spkr8.com/t/56641
http://pythonhosted.org/behave/
@adam_englander
#launchkey on freenode.net
#vegastech on freenode.net