当前位置:网站首页>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 .
边栏推荐
- matlab查找某一行或者某一列在矩阵中的位置
- Burp suite遇到的常见问题
- GBase 8a V8版本节点替换期间通过并发数控制资源使用减少对系统影响的方法
- 开源技术交流丨一站式全自动化运维管家ChengYing入门介绍
- Go from introduction to actual combat - context and task cancellation (notes)
- TreeSet details
- [LeetCode]515. 在每个树行中找最大值
- Go from introduction to practice - Interface (notes)
- QT base64 encryption and decryption
- Gbase 8A method for reducing the impact on the system by controlling resource usage through concurrency during node replacement of V8 version
猜你喜欢
∫(0→1) ln(1+x) / (x² + 1) dx
使用Jmeter进行性能测试的这套步骤,涨薪2次,升职一次
I think I should start writing my own blog.
win11桌面出現“了解此圖片”如何删除
Null pointer exception
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊
Go从入门到实战——任务的取消(笔记)
Go from introduction to practice -- shared memory concurrency mechanism (notes)
真香,自从用了Charles,Fiddler已经被我彻底卸载了
Luogu p5706 redistributing fertilizer and house water
随机推荐
vmware虚拟机PE启动
linux下安装oracle11g 静默安装教程
\w和[A-Za-z0-9_],\d和[0-9]等价吗?
Go from introduction to actual combat - context and task cancellation (notes)
Set code exercise
Null pointer exception
Figure countdownlatch and cyclicbarrier based on AQS queue
Oracle migration MySQL unique index case insensitive don't be afraid
语言弱点列表--CWE,一个值得学习的网站
Method of reading file contents by Excel
Summary of gbase 8A database user password security related parameters
Magic POI error in reading excel template file
正则表达式
软件缺陷管理——测试人员必会
[LeetCode]100. Same tree
哈希表-数组之和
[LeetCode]动态规划解拆分整数I[Silver Fox]
管理系统-ITclub(下)
QT base64 encryption and decryption
熊市慢慢,Bit.Store提供稳定Staking产品助你穿越牛熊