TestVagrant

Generating Allure Reports in the Pytest framework

generating allure reports in the pytest framework

Blog

Generating Allure reports in the Pytest framework​

This blog is a step-by-step guide to understand & implement allure test reports in a pytest framework.

Why Allure?

Allure Framework is a flexible lightweight multi-language test report tool that not only shows a very concise representation of what has been tested in a neat web report but allows everyone participating in the development process to extract the maximum useful information from the everyday execution of tests.

Let us now understand how can we add allure reporting support to the pytest framework.

Pre-requisite:

  • Python
  • Pip (Usually, Gets installed with python)
  • Pytest framework with a few test cases

Once we have all the required steps configured, Let’s start with the process of adding the allure support to the framework.

Installing allure-pytest library:

				
					pip install allure-pytest
				
			

That’s it, We need only this to be installed in our system, We can install it using pip (The above command) or if we are using pycharm we can head to Preference → Project → Project Interpreter → click on the + icon

A window name “Available Packages” will be opened

 

Search with “allure-pytest” → Select the first result → click on Install Package.

This will install the required package for allure-pytest.

Now, Just use the below flag with your existing command.

				
					pytest --alluredir= test.py
				
			

This will generate a directory to the specified path with some files in JSON format.

Generating Allure report:

Now, we have the supported data that will be required to get the report, We just need to convert it into HTML so that we can see this on the browser.

Hit the below command in the terminal/cmd

				
					allure serve 
				
			

Note: <path to report directory> this should be the same path where we generated the allure files.

It will start a jetty server within a few seconds and the report will be visible inside your browser.

This is it, following these few steps, we will be able to generate and see the report in the browser.

We can configure a lot more stuff inside the allure report like ENV, Severity, Trends, screenshot and etc. You can refer to the official documents for getting these features.

Hope the blog helped you to get a better understanding of how to generate Allure reports in the pytest framework. 

Other Related Articles

Scroll to Top