Skip to content
BDD, Python style.
Python Gherkin Other
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.attic CLEANUP: Remove deprecated parts. Jul 13, 2019
.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 Fixed a bug where use_fixture_by_tag didn't return the actual fixture… Aug 1, 2019
behave4cmd0 FIX warnings related to invalid escapes in regex. Jun 9, 2019
bin UTIL: Formatting tweaks. Jul 13, 2019
docs MENTION ENHANCEMENT: Support emojis in feature files and steps. Jul 6, 2019
etc Tweaks to update/generate from gherkin-languages.json Jul 7, 2019
examples Use runtime constraints Jul 13, 2019
features FIX: python3.8 regressions on CI server Jul 7, 2019
issue.features CHECK: Issue #766 -- PrettyFormatter: UnicodeError Aug 7, 2019
more.features more.features: Perform more Gherkin v6 checks and run examples. Jul 13, 2019
py.requirements Use cucumber-tag-expressions 1.1.2 (to fix warnings). Jul 6, 2019
tasks Tweaks to update/generate from gherkin-languages.json Jul 7, 2019
tests.attic DEPRECATING-CLEANUP: Move deprecated tag matcher classes Jun 9, 2019
tests Merge pull-request #767 with minor tweaks. Aug 7, 2019
tools/test-features FIX issue #309: behave --lang-list fails on Python3 (and Python2) Apr 15, 2015
.bumpversion.cfg Add support for runtime constraints. Jul 13, 2019
.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 Improve support for feature.background inheritance for rule.background. Jul 10, 2019
.pycheckrc Provide configfile for pychecker. Jul 7, 2013
.pylintrc CLEANUP: Pylint, whitespace, quoting related cleanups. Dec 27, 2015
.travis.yml FIX: Remove test/ from pytest run. Jul 6, 2019
CHANGES.rst Merge pull-request #767 with minor tweaks. Aug 7, 2019
LICENSE UPDATE: Increase year to 2014. Mar 2, 2014
MANIFEST.in REMOVE-DEPENDENCY: nose (to avoid nose.importer warnings) Jul 6, 2019
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.dev1 (was: 1.2.7.dev0) Mar 13, 2019
behave.ini FIX: python3.8 regressions on CI server Jul 7, 2019
conftest.py REMOVE-DEPENDENCY: nose (to avoid nose.importer warnings) Jul 6, 2019
invoke.yaml more.features: Perform more Gherkin v6 checks and run examples. Jul 13, 2019
pytest.ini Select-by-location: Add support for "Scenario container" Jul 6, 2019
setup.cfg upload: Only one format is allowed now, disable ZIP format. Feb 25, 2018
setup.py Improve support for feature.background inheritance for rule.background. Jul 10, 2019
setuptools_behave.py Tweak related to #310 Jun 14, 2015
tox.ini FIX: python3.8 regressions on CI server Jul 7, 2019

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

You can’t perform that action at this time.