BDD, Python style.
Clone or download
Permalink
Failed to load latest commit information.
.ci Use pytest instead of py.test per upstream recommendation, #dropthedot May 13, 2018
.github Formatting issue in stale-bot config Feb 20, 2018
behave Merge branch 'async_exceptions' of https://github.com/ALSchwalm/behave Jun 9, 2018
behave4cmd0 FIX: Windows regression test problems (or disable failing tests). Jan 24, 2017
bin pull #596: Add missing Czech translation (provided by: hason) Oct 8, 2017
docs Fix "Bleading edge" typo on install.rst Aug 14, 2018
etc pull #448 slightly adapted. Oct 1, 2016
examples Add encoding hint (and which python version is required). Feb 4, 2018
features FIX #657 und extend/adapt tests related to async-step failures. Jun 9, 2018
issue.features Provide test case to ensure that issue #673 is not a problem. Jul 18, 2018
more.features Add documented tutorial related to issue #233 problems. Jun 23, 2014
py.requirements TRAVIS-CI: setuptools tweaks. Jun 6, 2018
tasks release.upload: Add option skip_existing (default=False). Feb 25, 2018
test Add UserDataNamespace and use it in JUnitReporter. Jan 17, 2018
tests FIX #657 und extend/adapt tests related to async-step failures. Jun 9, 2018
tools/test-features FIX issue #309: behave --lang-list fails on Python3 (and Python2) Apr 15, 2015
.bumpversion.cfg BUMP-VERSION: 1.2.7.dev0 (was: 1.2.6; develop-mode-again now) Feb 25, 2018
.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 Fix issue #631: Minor adaptions to pull #642, add basic unit tests fo… Apr 7, 2018
.pycheckrc Provide configfile for pychecker. Jul 7, 2013
.pylintrc CLEANUP: Pylint, whitespace, quoting related cleanups. Dec 27, 2015
.travis.yml TRAVIS-CI: setuptools tweaks. Jun 6, 2018
CHANGES.rst UPDATE for #684 pull-request. Sep 6, 2018
LICENSE UPDATE: Increase year to 2014. Mar 2, 2014
MANIFEST.in Add gherkin-languages.json (from: cucumber-repo) to MANIFEST.in Feb 25, 2018
PROJECT_INFO.rst Add context-cleanups and fixture concept. Oct 1, 2017
README.rst Changed pythonhosted.org links to readthedocs.io Mar 3, 2018
VERSION.txt BUMP-VERSION: 1.2.7.dev0 (was: 1.2.6; develop-mode-again now) Feb 25, 2018
behave.ini PREPARED: Formatter-alias for AllureFormatter. Feb 4, 2018
conftest.py Unicode related fixes for #336, #424, #449, #453, #458 by using pull #… Oct 15, 2016
invoke.yaml clean-all: Add .pytest_cache as extra directory to clean up (created … Mar 18, 2018
pytest.ini RENAMED: requirements/ -> py.requirements/ Oct 28, 2016
setup.cfg upload: Only one format is allowed now, disable ZIP format. Feb 25, 2018
setup.py #662 Add comment to required setuptools version. Jun 9, 2018
setuptools_behave.py Tweak related to #310 Jun 14, 2015
tox.ini MINOR FIX: Replace old PYPI w/ new PYPI (related to #654). May 15, 2018

README.rst

Behave

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

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