当前位置:网站首页>Gao fushuai in the unit testing industry, pytest framework, hands-on teaching, will do this in the future test reports~
Gao fushuai in the unit testing industry, pytest framework, hands-on teaching, will do this in the future test reports~
2022-06-27 22:01:00 【Software testing】
One 、 Generate HTML The report
pytest Generate HTML There are a lot of plug-ins , such as pytest-html,pytest-testreport wait , Here is how to use pytest-testreport This plug-in generates HTML Test report .
1.1、 Installing a plug-in
pip install pytest-testreport
Be careful : If installed pytest-html Please uninstall this plugin first , Otherwise, there may be conflicts
1.2、 Introduction to the use of plug-ins
In the use of pytest When running tests , If you want to use pytest-testreport Generate test reports , Run the test with parameters --report Specify the report file name , That is to say .
Other operating parameters :
–title : Specify report title
–tester : Specify the tester in the report
–desc : Specify the item description in the report
–template : Specify the report template style (1 or 2)
Command line execution :
pytest --report=musen.html --title= Test report --tester= Munson --desc= Project description --template=2
The code uses pytest.main perform
import pytest
The generated report style is as follows
The style of a 
Style 2 
About HTML The format of report generation will be introduced here , Next, let's talk about how to integrate allure The report
Two 、 Integrate Allure The report
If you want to in pytest In the integration allure The report , You have to download it first allure, And configure the environment
2.1、allure Environment configuration
One 、 download allure:
Address :https://github.com/allure-framework/allure2/releases
Download and unzip
Two 、 Environment variable configuration
take allure After decompression allure The path of bin Put the directory path into the environment variable 
3、 ... and 、 install allure Of pytest plug-in unit
pip install allure-pytest
2.2、 Generate allure The report
Installed and configured allure After the environment , In the use of pytest When executing use cases , You can go through allure Plug-in parameters to specify the generation allure Here we go .
Operation parameters :
--alluredir : Appoint allure The path where the report is saved
Command line run
pytest --alluredir=reports
The code uses pytest.main perform
import pytest
2.3、 start-up allure service
Enter the following command at the command terminal , start-up allure service
# command :allure serve Generated report path
Execute the above command ,allure After the service is started, the browser will be opened automatically , Show allure Service page of 
2.4、allure Built in common methods
Add error screenshot
allure.attach
def error_save_screenshot(driver,file_path, desc):
Add the use case name in the report
allure.title
import allure
Use case names are dynamically set in parameterized use cases
allure.dynamic.title
# Use case data
Add function description in the report
allure.story
@allure.story(' Login function ')
Add the package name in the report
allure.suite
@allure.suite(' Log in to the test suite ')
The house needs to be built layer by layer , Knowledge needs to be learned at one point one . We should lay a good foundation in the process of learning , More hands-on practice , Don't talk much , The last dry goods here ! I stayed up late to sort out the stages ( function 、 Interface 、 automation 、 performance 、 Test open ) Skills learning materials + Practical explanation , Very suitable for studying in private , It's much more efficient than self-study , Share with you .
Get off w/x/g/z/h: Software testing tips dao
Typing is not easy , If this article is helpful to you , Click a like, collect a hide and pay attention , Give the author an encouragement . It's also convenient for you to find it quickly next time .
边栏推荐
- Software defect management - a must for testers
- .NET学习笔记(五)----Lambda、Linq、匿名类(var)、扩展方法
- STM32CubeIDE1.9.0\STM32CubeMX 6.5 F429IGT6加LAN8720A,配置ETH+LWIP
- Simulink method for exporting FMU model files
- ∫(0→1) ln(1+x) / (x² + 1) dx
- 快速excel导出
- Go from introduction to actual combat - task cancellation (note)
- Go from entry to practice -- CSP concurrency mechanism (note)
- Gbase 8A method for reducing the impact on the system by controlling resource usage through concurrency during node replacement of V8 version
- Null pointer exception
猜你喜欢

跟我一起AQS SOS AQS

Figure countdownlatch and cyclicbarrier based on AQS queue

Express e stack - small items in array

洛谷P5706 再分肥宅水

Go from introduction to practice -- coordination mechanism (note)

管理系统-ITclub(下)

win11桌面出现“了解此图片”如何删除

GBase 8a的create database 会被查询耗时很长怀疑卡住的现象分析

Remote invocation of microservices
![[leetcode] dynamic programming solution partition array ii[arctic fox]](/img/a1/4644206db3e14c81f9f64e4da046bf.png)
[leetcode] dynamic programming solution partition array ii[arctic fox]
随机推荐
IO stream code
Process control task
QT large file generation MD5 check code
[LeetCode]动态规划解拆分整数I[Silver Fox]
[LeetCode]186. Flip word II in string
Null pointer exception
.NET学习笔记(五)----Lambda、Linq、匿名类(var)、扩展方法
\W and [a-za-z0-9_], \Are D and [0-9] equivalent?
Go 访问GBase 8a 数据库的一个方法
Set code exercise
At 19:00 on Tuesday evening, the 8th live broadcast of battle code Pioneer - how to participate in openharmony's open source contribution in multiple directions
Burp suite遇到的常见问题
Magic POI error in reading excel template file
[leetcode] 508. Élément de sous - arbre le plus fréquent et
Knowledge sorting of exception handling
Stm32f107+lan8720a use stm32subemx to configure network connection +tcp master-slave +udp app
[LeetCode]30. 串联所有单词的子串
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
Bit. Store: long bear market, stable stacking products may become the main theme
Interview question 3 of software test commonly used by large factories (with answers)