- 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 - Reports
Report generation is one of the most important steps towards the test automation framework. At the end of the execution, we cannot rely on the console output rather we should have a detailed report.
It should have the information on the count of tests that passed, failed, skipped, feature and scenario breakdown. Behave does not produce an in-built report but it can output in multiple formats and we can utipze the third-party tools to generate a report.
All the available formatters in Behave are displayed with the command −
behave --format help
When you use the command, the following screen will appear on your computer −
Some of the common Behave reports are −
Allure Report.
Output JSON Report.
JUnit Report
JUnit Report
Let us execute a test having two feature files with the below test results −
Project folder structure for the above test will be as follows −
Step 1 − Execute the command
To create a JUnit report, run the command given below −
behave --junit
Step 2 − Report folder generation
A folder called as the reports gets generated within the project, having the name TESTS-<feature file name>.xml.
Here, Payment and Payment1 are the names of the feature files.
Step 3 − Report generation to a specific folder
To generate the reports to a specific folder, say my_reports. We have to run the below mentioned command −
behave --junit --junit-directory my_reports
A folder called the my_reports gets generated within the project which contains the reports.
JSON Report
We can create the Behave JSON report. The JSON is actually a formatter.
Let us execute a test having two feature files with the below test results −
Project folder structure for the above test is as follows −
Step 1 − Execute the command
To create a JSON output in console, run the command −
behave -f json
The following screen will appear −
Step 2 − Output in readable format
To create a JSON output in a more readable format, run the following command −
behave -f json.pretty
Some portion of the output captured in the below image −
Step 3 − Report generation to a specific folder
To generate the reports to a specific folder say, my_reports.json, we have to run the following command −
behave –f json.pretty –o my_reports.json
The following image represents the screen that will appear on your computer.
A folder called the my_reports.json gets generated within the project, having details of all the features which are executed.
Allure Report
To generate Allure reports in Behave, first we have to install Allure in the system. For installation from the command pne in Linux, run the following commands one after the other −
sudo apt-add-repository ppa:qameta/allure sudo apt-get update sudo apt-get install allure
For Mac users, installation is done with the Homebrew with the following command −
brew install allure
For Windows, Allure is installed from the Scoop installer. Run the below command to download and install Scoop and finally, execute it in the PowerShell −
scoop install allure
To update Allure distribution installations from Scoop, run the below command from the installation directory of Scoop −
incheckver.ps1 allure -u
Finally, run the command given below −
scoop update allure
After Allure has been installed, we have to get the Allure-Behave integration plugin for Python. For this, run the following command −
pip install allure-behave
To verify if Allure has been installed successfully, run the command stated below −
allure
Let us execute a test having two feature files with the below test results −
Project folder structure for the above test is as follows −
Step 1 − Report generation to a specific folder
To generate the reports to a specific folder, say my_allure, we have to run the following command −
behave -f allure_behave.formatter:AllureFormatter –o my_allure
You will get the screen as shown below −
A folder called the my_allure gets generated within the project, having files with .json extension.
Step 2 − Start the web server
To start the web server, run the command given below −
allure serve my_allure
Here, the my_allure is the directory which contains the allure json files.
Simultaneously, a browser gets opened, with the Allure report as shown below −
We can also cpck on inspanidual features and find their breakdowns, as shown below −
Advertisements