Generating Allure reports in the Pytest framework

Vinay Sharma
TestVagrant
Published in
3 min readJun 16, 2022

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=<path to report directory> 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 <path to report directory>

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.

Thank You! Feel free to reach out to me for any queries.

--

--