Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of building pytest+Allure and the example analysis of generating report

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces the building method of pytest+Allure and the example analysis of generating report, which is very detailed and has certain reference value. Friends who are interested must read it!

1. Allure build 1. Download Allure installation package

Link: https://github.com/allure-framework/allure2/releases

2. Install the allure-pytest library

Enter commands on the cmd command line:

Pip install allure-pytest

3. Configure allure environment variables

In the Path environment variable, enter the address of the allure

4. Verify that allure is installed successfully

Enter allure on the command line

2. Allure generates report code 1. Allure specifies the severity level of the use case:

Blocker (blocking defect); critical (serious defect); normal (General defect); minor (minor defect); trivial (minor defect)

Code:

"- allure-severities=blocker,critical,normal"

2. Allure specifies the marked test case execution

Example @ allure.story ('xx') method, and other @ allure.feature (' xx') tags can also be implemented

Code:

"--allure-stories= Automation use case-search term, Automation use case-Direct word"

3. Generate report code

Generate to the specified directory or to the current pycharm local directory

Recommendation: create a new temp file in advance to store script data

Pytest.main (["- allure-severities=blocker,critical,normal", # "- allure-stories= automation use case-search term, automation use case-direct word", "test_AppIos_run.py", "- alluredir" "D:\\ AllureReport\\ temp"]) os.system ("allure generate D:\\ AllureReport\\ temp-o D:/AllureReport/reports-- clean") # the report is written to the pycharm local directory Automatically generate the corresponding folder # pytest.main (["- s", "test_RomweIos_run.py", "--alluredir", ". / temp"]) # os.system ("allure generate. / temp-o. / reports-- clean")

Notice that the allure report under the specified directory is opened:

Generate to the specified directory of other disks, and you need to turn on the corresponding server to display the report normally.

Reason: PyCharm has its own container service, and the corresponding port runs allure report. If it is not opened in pycharm, you need to open a container service locally to run the test report.

1. Install anywhere

AnyWhere is a static file server that can change your current directory to the root of a static file server anytime, anywhere.

Npm install-g anywhere

2. After the installation is successful, enter the directory where the report is located

Example: go to the AllureReport file directory of D disk

(1) enter d: enter disk D on the command line

(2) cd / specified folder

3. Start the anywhere service in the corresponding folder

Enter anywhere, enter the page to pop up the files in this directory, and click the corresponding allure report to open it.

4. Open the report

Other methods: install Tomcat, put the report under the webapps file, start the Tomcat service, and open the corresponding report page.

The above is all the content of the article "pytest+Allure Building method and sample Analysis of generating report". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report