BDD, Python style.
Python Gherkin Other
Permalink
Failed to load latest commit information.
.ci Appveyor tweak: detect encoding (part 2) Jan 29, 2017
behave plain formatter: Reenable output errors. Jan 29, 2017
behave4cmd0 FIX: Windows regression test problems (or disable failing tests). Jan 24, 2017
bin Helper script to determine default encoding on a platform. Jan 29, 2017
docs Merge pull request #447 from bittner/feature/allow-tox-ini-config-file Nov 16, 2016
etc pull #448 slightly adapted. Oct 1, 2016
examples pytest testrun: Add behave version to report info (pytest --html=repo… Oct 1, 2016
features Add missing active-tag for python3.6 Jan 29, 2017
issue.features Add active-tag support for CI server (part 3). Jan 29, 2017
more.features Add documented tutorial related to issue #233 problems. Jun 23, 2014
py.requirements UPDATE: Tests on Windows. PREPARE: release. Dec 29, 2016
tasks UPDATE: Tests on Windows. PREPARE: release. Dec 29, 2016
test REFACTORING: Move capture/capture controller functionality from runner Oct 29, 2016
tests Tests on Windows tweaks. Dec 29, 2016
tools/test-features FIX issue #309: behave --lang-list fails on Python3 (and Python2) Apr 15, 2015
.bumpversion.cfg UPDATE: bumpversion 0.5.3 Dec 12, 2016
.coveragerc UPDATE: coverage 4.2 Dec 12, 2016
.editorconfig Provide generic editor configuration description for this project. Oct 13, 2013
.gitattributes Tweaks Oct 15, 2016
.gitignore Unicode related improvements. Mar 13, 2016
.pycheckrc Provide configfile for pychecker. Jul 7, 2013
.pylintrc CLEANUP: Pylint, whitespace, quoting related cleanups. Dec 27, 2015
.travis.yml Travis CI: Use Python3.6 instead of Python3.6-dev Jan 24, 2017
CHANGES.rst Add info to merged pull-request #447 Nov 16, 2016
LICENSE UPDATE: Increase year to 2014. Mar 2, 2014
MANIFEST.in UPDATE: Tests on Windows. PREPARE: release. Dec 29, 2016
PROJECT_INFO.rst UPDATE/FIX: Use shorter URL to rtfd.org (that is available since the … Feb 6, 2017
README.rst Correct URLs after moving "behave.example" to owner=behave (was: owne… Mar 31, 2016
VERSION.txt BUMP-VERSION: 1.2.6.dev0 (was: 1.2.5) Jan 31, 2015
behave.ini Merge pull request #447 from bittner/feature/allow-tox-ini-config-file Nov 16, 2016
conftest.py Unicode related fixes for #336, #424, #449, #453, #458 by using pull #… Oct 15, 2016
invoke.yaml UPDATE: Tests on Windows. PREPARE: release. Dec 29, 2016
pytest.ini RENAMED: requirements/ -> py.requirements/ Oct 28, 2016
setup.cfg UPDATE: Tests on Windows. PREPARE: release. Dec 29, 2016
setup.py Use Status enum-class now for feature/scenario/step.status (was: stri… Oct 23, 2016
setuptools_behave.py Tweak related to #310 Jun 14, 2015
tox.ini UPDATE: Tests on Windows. PREPARE: release. Dec 29, 2016

README.rst

Behave

Join the chat at https://gitter.im/behave/behave Travis CI Build Status Latest Version Downloads License

behave is behavior-driven development, Python style.

logo

Behavior-driven development (or BDD) is an agile software development technique that encourages collaboration between developers, QA and non-technical or business participants in a software project.

behave uses tests written in a natural language style, backed up by Python code.

First, install *behave*.

Now make a directory called "features/". In that directory create a file called "example.feature" containing:

# -- FILE: features/example.feature
Feature: Showing off behave

  Scenario: Run a simple test
    Given we have behave installed
     When we implement 5 tests
     Then behave will test them for us!

Make a new directory called "features/steps/". In that directory create a file called "example_steps.py" containing:

# -- FILE: features/steps/example_steps.py
from behave import given, when, then, step

@given('we have behave installed')
def step_impl(context):
    pass

@when('we implement {number:d} tests')
def step_impl(context, number):  # -- NOTE: number is converted into integer
    assert number > 1 or number == 0
    context.tests_count = number

@then('behave will test them for us!')
def step_impl(context):
    assert context.failed is False
    assert context.tests_count >= 0

Run behave:

$ behave
Feature: Showing off behave # features/example.feature:2

  Scenario: Run a simple test          # features/example.feature:4
    Given we have behave installed     # features/steps/example_steps.py:4
    When we implement 5 tests          # features/steps/example_steps.py:8
    Then behave will test them for us! # features/steps/example_steps.py:13

1 feature passed, 0 failed, 0 skipped
1 scenario passed, 0 failed, 0 skipped
3 steps passed, 0 failed, 0 skipped, 0 undefined

Now, continue reading to learn how to get the most out of behave. To get started, we recommend the tutorial and then the feature testing language and api references.

More Information