Pytest+Allure generates automated test reports!

Preface

In automated testing, there isunittest+HTMLTestRunner automated test report, but the generated test report is not beautiful and detailed enough. Let’s learn about it today. Pytest+Allure generates automated test reports.

1: Install all dependency libraries in python

In the dos window, enter the following three commands:

pip3 install pytest

pip3 install allure-python

pip3 install allure-python-commons

2: After installing the dependent libraries, download and decompress the allure command line tool. Download address: https://pan.baidu.com/s/1YkgYpvfmH_I26ZPAJ1OF0A. Set the unzipped allure folder as an environment variable. Add allure to the environment variable PATH, in the bin directory

Three: Confirm that allure is installed successfully, enter: allure --version on the command line, and it will display the allure installation version 2.12.1.

Four: Write automated test scripts through pytest, as shown below. Writing pytest test cases is very simple, just follow the following rules:

  • Test files start with test_

  • Test classes start with Test

  • Test functions start with test_

 Five: Open the DOS window, switch to the current project folder, execute the command pytest -s -q, and the returned results will be printed on the command line.

 Six:After creating the test case, execute the command in the dos window: pytest -s -q --alluredir allure-xml. The test case will then be run. -s means to allow the terminal to output results when the test is running, -q means to simplify the output results, and --alluredir means to save the generated intermediate results to the allure-xml folder.

Seven: Wait for the test case to be executed. Continue to execute the command in Terminal: allure generate allure-xml -o allure-report --clean. This will generate a test report in the allure-report folder based on the intermediate results in the allure-xml folder.

Eight: The generated html test report can be opened with a browser

 

In this way, a simple allure automated test report is generated

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.

 

Guess you like

Origin blog.csdn.net/2301_79535733/article/details/134856727