allure plug-in novice demo

Keywords: Testing

allure is a plug-in that can generate visual test reports. It has the following characteristics:

  • allure is a lightweight, flexible and multilingual test reporting tool
  • Multi platform and luxurious report framework;
  • Can be dev/qa   Provide detailed test report, test steps and log;
  • It can also provide high-level statistical reports for the management;
  • Developed in Java language, supporting pytest, JaveScript,   PHP, ruby, etc
  • Can be integrated into Jenkins

The following is a novice demo tutorial for the integration of allure plug-in and pytest, which is a tutorial reference   allure official documentation.

1. Install alure

The following is the installation command of mac system. For other systems, please Click here View installation method

brew install allure

2. Install the allure pytest plug-in

This plug-in is used to integrate with pytest and collect the execution of pytest runtime case.

The installation command is   pip install allure-pytest

$ pip install allure-pytest

3. Write case and configure environment

I've created one here called allure_test folder. There are only two files and one folder under the folder, and one of the two files is empty__ file, and the other is The allure result folder is used to store test reports. There are three necessary configuration files. The contents of each file are described below.

    ├── # Empty file
    ├── # test case file
    └── allure-result      # Test results folder
             ├── categories.json
             └── environment.xml


This is the case of pytest execution. You can see that there are four cases, one successful case, one skipped case and two failed cases.

import pytest

def test_success():
    """this test succeeds"""
    assert True

def test_failure():
    """this test fails"""
    assert False

def test_skip():
    """this test is skipped"""
    pytest.skip('for a reason!')

def test_broken():
    raise Exception('oops')

Allure result folder

The three files in this folder are environment configuration files. Put these three configuration files in which folder you want to generate test reports. At present, the role of each configuration file is not very clear. The following is the content of each configuration file. You can copy it directly without modification.


    "name": "Ignored tests",
    "matchedStatuses": [
    "name": "Infrastructure problems",
    "matchedStatuses": [
    "messageRegex": ".*bye-bye.*"
    "name": "Outdated tests",
    "matchedStatuses": [
    "traceRegex": ".*FileNotFoundException.*"
    "name": "Product defects",
    "matchedStatuses": [
    "name": "Test defects",
    "matchedStatuses": [




4. Run the case and set the test report saving path

The current terminal enters allure_ Under the test path, execute the following command. pytest executes case with -- allouredir   Parameter indicates the path to save the test report.

pytest --alluredir=./allure-result

The following is the running result. One case succeeded, two cases failed and one case skipped. As we expected.

5. Generate online html visualization Report

Use allure to generate online html test reports. Continue to execute allure serve. / allure result on the current terminal

allure serve ./allure-result

If you see the following execution results, the execution is successful

Then we will automatically jump to the browser and display our test report in a new tab.

Click the navigation bar on the left to see the execution of each case

The above contents are for reference   allure official documentation , a few references: Introduction and use of python allure (under continuous update)

Posted by asherinho on Sun, 31 Oct 2021 03:52:40 -0700