当前位置:网站首页>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 .
边栏推荐
- Xiao Wang's interview training task
- \w和[A-Za-z0-9_],\d和[0-9]等价吗?
- GBase 8a OLAP分析函数cume_dist的使用样例
- Remote invocation of microservices
- Go from introduction to practice - Interface (notes)
- Burp suite遇到的常见问题
- 【Redis】零基础十分钟学会Redis
- [LeetCode]动态规划解分割数组II[Arctic Fox]
- IO stream code
- Method of reading file contents by Excel
猜你喜欢

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

Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
![[leetcode] dynamic programming solution partition array i[red fox]](/img/b2/df87c3138c28e83a8a58f80b2938b8.png)
[leetcode] dynamic programming solution partition array i[red fox]
![[LeetCode]动态规划解分割数组I[Red Fox]](/img/b2/df87c3138c28e83a8a58f80b2938b8.png)
[LeetCode]动态规划解分割数组I[Red Fox]

Slow bear market, bit Store provides stable stacking products to help you cross the bull and bear

管理系统-ITclub(下)

百万年薪独家专访,开发人员不修复bug怎么办?

单元测试界的高富帅,Pytest框架,手把手教学,以后测试报告就这么做~

AQS SOS AQS with me

Burp suite遇到的常见问题
随机推荐
Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
[LeetCode]动态规划解分割数组II[Arctic Fox]
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
QT large file generation MD5 check code
STM32CubeIDE1.9.0\STM32CubeMX 6.5 F429IGT6加LAN8720A,配置ETH+LWIP
语言弱点列表--CWE,一个值得学习的网站
我想我要开始写我自己的博客了。
Go from introduction to actual combat - only any task is required to complete (notes)
Special tutorial - Captain selection game
[MySQL] database function clearance Tutorial Part 2 (window function topic)
C语言程序设计详细版 (学习笔记1) 看完不懂,我也没办法。
How to delete "know this picture" on win11 desktop
快速excel导出
美团20k软件测试工程师的经验分享
MYSQL和MongoDB的分析
Go从入门到实战——错误机制(笔记)
Sharing | intelligent environmental protection - ecological civilization informatization solution (PDF attached)
Go从入门到实战——任务的取消(笔记)
Figure countdownlatch and cyclicbarrier based on AQS queue
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