Application of Allure in Automated Testing

01 Introduction and use of Allure

1. Application scenarios

The result of automation must be reflected in a report

Allure is an independent report plugin that generates beautiful and easy-to-read reports. It currently supports Python, Java, PHP, C# and other languages.

Provide detailed test reports, test steps, logs for dev/QA, and also provide statistical reports for management

Can be integrated into Jenkins

Install the allllure executable

The Windows environment can directly use the package (refer to the toolkit) to configure environment variables after decompression

Verify that allure is installed successfully

Mac:

brew install allure

Install the plugin:

pip install allure-pytest==2.8.16

Pay attention to the pytest version matching problem

picture

In the end, we will generate a report in html format, and we need to do two steps in the middle.

Execute to generate json, specify the result save directory

pytest --alluredir=report test_demo.py

View test report method

Convert json to html and use allure generate to generate test report in html format

a. Enter the report parent directory to execute the command

b.allure generate report/ -o report/html --clean

The html folder will be generated in the c.report directory, and there will be a d.index.html under html, right click to open it with a browser

What does allure generate report/ -o report/html --clean mean?

picture

02 Combining Allure with Pytest

1. Add test steps

picture

The report shows:

picture

2. Add description of main function modules

picture

The report shows:

picture

3. Add severity level

There are five parameters, which also correspond to different priorities, just replace the last word

BLOCKER is the worst

CRITICAL

NORMAL

MINOR is not serious

TRIVIAL Least severe

picture

The report shows:

picture

03 Allure integrates Jenkins

1. Jenkins introduction and installation

Application scenarios

After writing the code of an automated test project, you need to use pytest to run it on the command line, and then use the command line to generate an allure report, which can be done automatically with jenkins.

introduce

Jenkins is an open source software project. It is a continuous integration tool developed based on Java. It is used to monitor continuous repetitive work and provide an open and easy-to-use software platform.

Installation method: (recommended decompression package installation)

Need to rely on the java environment

Command line to enter the directory where Jenkins.war is located

Type java -jar jenkins.war

After the startup is successful, the browser enters the address: localhost:8080

Enter the directory of the individual user through the command, find the .jenkins folder and replace the .jenkins in the toolkit

2. Jenkins installs the allure plugin

Scenes

Use Jenkins to help us generate allure report files, you need to install plugins

Installation process:

Jenkins main page click system management

Click Manage Plugins

Click on the optional plug-in - enter allure in the search box and click directly to install

jenkins install allure commandline tool

Scenes:

This tool is required to convert the format of the allure report to html format

Installation process:

Click System Management

Click on Global Tool Configuration

allure commandline

Click allure commandlin to install

installation directory – local configuration environment variable path

picture

alias: custom

Cancel the automatic installation and click Save

3. Jenkins continuous integration configuration

Prerequisites: Write automation scripts to ensure smooth operation with pycharm

Create a new jenkins project

Click New

insert image description here

custom task name

Click Build a Freestyle Software Project and click OK
insert image description here

General settings

Click Advanced

insert image description here

custom workspace

Address can fill in the project address
insert image description here

Build a Windows environment

Switch to the project path - execute the pytest command

insert image description here

Post-build actions

Note that the save directory is the same as the command directory

insert image description here

Click Advanced

Fill in the html file generation path, click save

insert image description here

View report

Click on allure report

insert image description here

View console output information

Click the corresponding item

insert image description here

Click on console output

insert image description here

Display output information

insert image description here

Guess you like

Origin blog.csdn.net/Testfan_zhou/article/details/124141607
Recommended