Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 behave
Octocat-spinner-32 docs
Octocat-spinner-32 test
Octocat-spinner-32 tools
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .travis.yml
Octocat-spinner-32 LICENSE
Octocat-spinner-32 MANIFEST.in
Octocat-spinner-32 README.rst
Octocat-spinner-32 setup.cfg
Octocat-spinner-32 setup.py
Octocat-spinner-32 tox.ini
README.rst

Behave

behave is behaviour-driven development, Python style

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 impl(context):
    pass

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

@then('behave will test it for us!')
def impl(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.2.2 - August 21, 2012

  • Fix for an error when an assertion message contains Unicode characters.
  • Don't repr() the step text in snippets to avoid turning Unicode text into backslash hell.

Version 1.2.1 - August 19, 2012

  • Fixes for JSON output.
  • Move summary reporter and snippet output to stderr.

Version 1.2.0 - August 18, 2012

  • Changed step name provided in snippets to avoid issues with the @step decorator.
  • Use setup to create console scripts.
  • Fixed installation on Windows.
  • Fix ANSI escape sequences for cursor movement and text colourisation.
  • Fixes for various command-line argument issues.
  • Only print snippets once per unique step.
  • Reworked logging capture.
  • Fixes for dry-run mode.
  • General fixes.

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
Something went wrong with that request. Please try again.