Introduction¶
Read the Documentation¶
Before you start reading this manual, you should have read the behave documentation to understand how behave works.
Given, When, Then¶
You should understand the BDD concepts.
Feature: Title (one line describing the story/feature)
As a [role]
I want [feature]
So that [benefit]
Scenario: Title1 (for Behaviour 1)
Given [context or setup]
And [some more context]...
When [event occurs]
Then [expected outcome]
And [another outcome]...
Scenario: Title2 (for Behaviour 2)
...
Select an Assertion Matcher Library¶
Before you start to use behave (or any other BDD framework) you should select an assertion matcher library that you want to use in your project.
Python has a growing number of assertion matcher libraries by now. Here is the list of some of these:
Matcher Library |
Description |
---|---|
Native assert |
Starting point, but not enough information when assert fails. |
First assertion matcher library, now part of JUnit4. Supports several programming languages: github:/hamcrest/PyHamcrest |
|
Enables pytest assertions in behave: (old repo: github:/ribozz/behave-pytest currently not usable) |
|
Part of the nose test framework |
|
An interesting small matcher library, https://pypi.org/project/should_dsl |
|
Provided by the maker of lettuce, github:/gabrielfalcao/sure |
|
Note
hamcrest is used as assertion matcher library in the examples presented here.