Skip to main content

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 “example”. In that directory create a file called “example.feature” containing:

Feature: showing off behave

  Scenario: run a simple test
     Given we have behave installed
      when we implement a test
      then behave will test it for us!

Make a new directory called “example/steps”. In that directory create a file called “example.py” containing:

from behave import *

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

@when('we implement a test')
def step(context):
    assert True is not False

@then('behave will test it for us!')
def step(context):
    assert context.failed is False

Run behave:

% behave
Feature: showin off behave # example/example.feature:1

  Scenario: run a simple test        # example/example.feature:3
    Given we have behave installed   # example/steps/example.py:3
    When we implement a test         # example/steps/example.py:7
    Then behave will test it for us! # example/steps/example.py:11

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 the most of behave. To get started, we recommend the tutorial and then the feature testing language and api references.

Download from http://pypi.python.org/pypi/behave

Version History

Version 1.1.0 - January 23, 2012

  • Context variable now contains current configuration.

  • Context values can now be tested for (name in context) and deleted.

  • __file__ now available inside step definition files.

  • Fixes for various formatting issues.

  • Add support for configuration files.

  • Add finer-grained controls for various things like log capture, coloured output, etc.

  • Fixes for tag handling.

  • Various documentation enhancements, including an example of full-stack testing with Django thanks to David Eyk.

  • Split reports into a set of modules, add junit output.

  • Added work-in-progress (“wip”) mode which is useful when developing new code or new tests. See documentation for more details.

Version 1.0.0 - December 5, 2011

  • Initial release

Release files for behave 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for behave 1.1.0
File Size Uploaded
behave-1.1.0.tar.gz 48.6 kB Details

Release files / behave-1.1.0.tar.gz

Download URL behave-1.1.0.tar.gz
Size 48.6 kB
Tags Source
SHA-256 checksum
How to use checksums
de77ceb5e81cbe3d44f3d3c47a96be938aa64d83f80d1d74bd701cfb35253c76
BLAKE2b-256 checksum
How to use checksums
3cd6b86a3e4869f273c90031d9c8b4b03d21bd4f28951d927af642d17dc792fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

1.3.3

2 release files

1.3.2

2 release files

1.3.1

2 release files

1.3.0

2 release files

1.2.6

2 release files

1.2.5

4 release files

1.2.4

1 release file

1.2.3

1 release file

1.2.2

1 release file

1.2.1

1 release file

1.2.0

1 release file

This release

1.1.0 This release

1 release file

1.0.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page