Behaviour Driven Development in Python Introduction |
|
Translator:
| Kaur, Gurpreet |
Author:
| Kaur, Gurpreet |
ISBN: | 979-8-3612-5463-7 |
Publication Date: | Oct 2022 |
Publisher: | Independently Published
|
Book Format: | Paperback |
List Price: | USD $23.69 |
Book Description:
|
Behave is a Python programming tool for Behaviour-Driven Development (BDD). BDD fosters a culture where testers, developers, business analysts, and other project stakeholders can all participate to the software development process within an Agile development framework. In summary, both technical and non-technical people contribute to the project as a whole. Behave has written tests in plain text with Python serving as the implementation language. The BDD format...
More Description Behave is a Python programming tool for Behaviour-Driven Development (BDD). BDD fosters a culture where testers, developers, business analysts, and other project stakeholders can all participate to the software development process within an Agile development framework.
In summary, both technical and non-technical people contribute to the project as a whole. Behave has written tests in plain text with Python serving as the implementation language.
The BDD format begins with the description of the characteristics of the software similar to a story.
It then continues with the development and carries out the following tasks −
- Developing a failing test case for characteristics.
- Implement the logic for a test to pass.
- Code refactor to fulfil the project guidelines.
There are many libraries for BDD, including the JavaScript-compatible Mocha, the Java/Ruby-compatible Cucumber, the Python-compatible Behave, and many others.
We will go into detail regarding behave in this tutorial.
Let us see a basic structure of a BDD. It mainly consists of the feature file, the step definition file, and so on.
Feature File
The feature file in Behave may look like this:
Verify book name added in library is a feature.
Verify Book name scenario
given Book information.
then confirm the book's name.
Corresponding step definition file
Following is the corresponding definition file in Behave tool −
from behave import *
@given('Book details')
def impl_bk(context):
print('Book details entered')
@then('Verify book name')
def impl_bk(context):
print('Verify book name')