Allure2: A GUI for your code tests

In my previous post I touched on the basics of how you can use pytest to test your code. In this post I’ll be covering how you can use Allure2 to prettify your pytest results.

Allure2 Adapter for pytest

The first thing we need to is install the Allure adapter for Pytest. As the documentation states, this repository contains a plugin for py.test which automatically prepares input data used to generate Allure Report.

Issue the following command to install the adapter:

Download Allure2

Next we need to head over to the Allure2 documentation. There are multiple installation options. As I don’t use linuxbrew, I opted for the manual installation method.

In order to do a manual installation, we’ll need to download the tar file from bintray and untar it:

Next we move Allure2 to the /usr/bin directory.

We then add the path to the Allure2 binary to my PATH:

Finally, we’ll need to open a new SSH session to our Linux box.

Note: This step is very important and is required in order to take advantage of the new PATH entry. See the Ubuntu documentation for more information.

Download Java

You should now be able to access Allure2. However, if you don’t have Java installed you’ll need to do that now:

Once the installation is finished, you should be able to run Allure2 without issue:

Basic Test

To see Allure2 in action, you’ll need to create a test script or scripts. As I was writing scripts for the purpose of this post, I put mine in a temporary directory:

The contents of is as follows:

I’ve intentionally created one test which will pass and one that will fail. Let’s now run pytest along with the Allure adapter we installed at the beginning of this post:

To ensure that our adapter worked, let’s take a look at the outputs it produced:

Excellent, we see that it’s created a couple of JSON files which contain the results of our test. Let’s now create an Allure2 report:

Now let’s check that our report was generated correctly:

Great, that looks good to me. Let’s now look at the actual report. To do this, we’ll need to navigate to the index.html file and open it.

Allure2 GUI

Opening the index.html file will give you a full report of what worked, and what didn’t. The example screenshot below shows the “Graphs” page. For a full, interactive demo, please see the Allure2 demo page.

Knowledge Base

See the Coding section of my Knowledge Base for more information.
As always, if you have any questions or have a topic that you would like me to discuss, please feel free to post a comment at the bottom of this blog entry, e-mail at, or drop me a message on Twitter (@OzNetNerd).

Note: This website is my personal blog. The opinions expressed in this blog are my own and not those of my employer.