Behave Tutorial
Selected Reading
- 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 - First Steps
Behave - First Steps
Let us create a basic Behave test.
Feature File
The feature file for the Feature titled Payment Types is as follows −
Feature − Payment Types Scenario − Verify user has two payment options Given User is on Payment screen When User cpcks on Payment types Then User should get Types Cheque and Cash
Corresponding Step Implementation File
The corresponding step implementation file for the above mentioned feature is as follows −
from behave import * @given( User is on Payment screen ) def impl_bkpy(context): print( User is on Payment screen ) @when( User cpcks on Payment types ) def impl_bkpy(context): print( User cpcks on Payment types ) @then( User should get Types Cheque and Cash ) def impl_bkpy(context): print( User should get Types Cheque and Cash )
Project Structure
The project structure for the feature “Payment Types” is as follows −
Output
The output obtained after running the feature file is as mentioned below and the command used here is behave
The output shows the Feature and Scenario names, along with test results, and duration of test execution.
Python Console output is given below −
Advertisements