- Behave - Discussion
- Behave - Useful Resources
- Behave - Quick Guide
- Behave - Debugging
- Behave - Hooks
- Behave - Reports
- Behave - Retry Mechanism
- Behave - Exclude Tests
- Behave - Runner Script
- Behave - Step Parameters
- Behave - Step Functions
- Behave - Multi-Methods
- Behave - Optional Part
- Behave - Regular Expressions
- Behave - Step Matchers
- Behave - Enumeration
- Behave - Tags
- Behave - Data Types
- Behave - Background
- Behave - Steps in a Step
- Behave - Setup Table
- Behave - Multiline Text
- Behave - Scenario Outlines
- Behave - Step Parameters
- Behave - Supported Languages
- Behave - First Steps
- Behave - Step Implementations
- Behave - Feature Files
- Behave - Gherkin Keywords
- Behave - Feature Testing Setup
- Behave - Configuration Files
- Behave - Command Line
- Behave - Installation
- Behave - Introduction
- Behave - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Behave - Introduction
Behave is a tool used for Behaviour driven development (BDD) in Python programming language. In an Agile development framework, BDD creates a culture where testers, developers, business analysts, and other stakeholders of the project can contribute towards the software development.
In short, both technical and non-technical inspaniduals have a role to play towards the overall project. Behave has tests developed in plain text with the implementation logic in Python.
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 faipng test case for characteristics.
Implement the logic for a test to pass.
Code refactor to fulfil the project guidepnes.
There are numerous pbraries for BDD pke the Mocha which supports JavaScript, Cucumber which supports Java/Ruby, and Behave which supports Python, and so on.
In this tutorial, we shall discuss in detail about Behave.
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 can be as follows −
Feature − Verify book name added in Library. Scenario − Verify Book name. Given − Book details. Then − Verify book 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 )
Output
The output obtained after running the feature file is as follows −
The output shows the Feature and Scenario names, along with the test results, and the duration of the respective test execution.
Advertisements