The application of Allure in automated testing!

01. Introduction and use of Allure

1. Application scenarios

The results of automation must be reflected in a report.

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

​​to provide dev/QA with detailed test reports, test steps, Logs can also provide statistical reports for management

and can be integrated into Jenkins
  • Install allure executable file
  • In Windows environment, you can directly use the package (reference tool package) to unzip and configure environment variables.
  • Verify whether allure is installed successfully

Mac:

brew install allure

Install plugin :

pip install allure-pytest==2.8.16

Pay attention to the pytest version matching problem

Finally, we will generate a report in html format , and we need to perform two steps in the middle.

  • Execute to generate json and specify the directory where the results are saved.
pytest --alluredir=report test_demo.py

View test report method

Convert json to html and use allure generate to generate a test report in html format
a. Enter the upper-level directory of report and execute the command
b.allure generate report/ -o report/html --clean
c.report The html folder will be generated in the directory, under html There will be a d.index.html, right click and open it with the browser

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

现在我也找了很多测试的朋友,做了一个分享技术的交流群,共享了很多我们收集的技术文档和视频教程。
如果你不想再体验自学时找不到资源,没人解答问题,坚持几天便放弃的感受
可以加入我们一起交流。而且还有很多在自动化,性能,安全,测试开发等等方面有一定建树的技术大牛
分享他们的经验,还会分享很多直播讲座和技术沙龙
可以免费学习!划重点!开源的!!!
qq群号:110685036

 

02. Combination of Allure and Pytest

1. Add test steps

The report shows:

2. Add description of main function modules

The report shows:

3. Add severity level

There are five parameters, which also correspond to different priorities. You only need to replace the last word.

  • BLOCKER The most serious
  • CRITICAL serious
  • NORMAL normal
  • MINOR Not serious
  • TRIVIAL least serious

The report shows:

03. Allure integrates Jenkins

1. Jenkins introduction and installation

Application scenarios

After writing the code for 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. These operations can be completed automatically using 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 provides an open and easy-to-use software platform.

Installation method: (recommended to unzip the package for installation)

  • Need to rely on java environment
  • Enter the directory where Jenkins.war is located using the command line
  • Enter java -jar jenkins.war
  • After successful startup, enter the address in the browser: localhost:8080

Enter the personal user's directory through the command, find the .jenkins folder, and replace the .jenkins in the tool package.

2. Install allure plug-in in Jenkins

Scenes

Use Jenkins to help us generate allure report files, you need to install the plug-in

Installation process:

  • Click System Management on the main page of Jenkins
  • Click Manage Plugins
  • Click on optional plug-ins--enter allure in the search box and click to install directly

jenkins installs allure commandline tool

Scenes:

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

Installation process:

  • Click System Management
  • Click global tool configuration
    allure commandline
  • Click allure commandlin to install
  • Installation directory--local configuration environment variable path

  • Alias: Custom
  • Cancel automatic installation and click Save

3. Jenkins continuous integration configuration

Prerequisite: Write automated scripts to ensure smooth operation using pycharm

Create a new jenkins project

Click New

Custom task name

Click to build a free-style software project and click OK

General settings

Click Advanced

Custom workspace

Address can fill in the project address

Building a Windows environment

Switch to the project path--execute the pytest command

Post-build operations

Note that the save directory is consistent with the command directory.

Click Advanced

Fill in the html file generation path and click Save

View report

Click all report

View console output information

Click on the corresponding item

Click console output

display output information

Finally, I would like to thank everyone who read my article carefully. Looking at the increase in fans and attention, there is always some courtesy. Although it is not a very valuable thing, if you can use it, you can take it directly!

Software Testing Interview Document

We must study to find a high-paying job. The following interview questions are from the latest interview materials from first-tier Internet companies such as Alibaba, Tencent, Byte, etc., and some Byte bosses have given authoritative answers. After finishing this set I believe everyone can find a satisfactory job based on the interview information.
 

Insert image description here

Guess you like

Origin blog.csdn.net/jiangjunsss/article/details/132858078