当前位置:网站首页>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 .
边栏推荐
猜你喜欢

win11桌面出現“了解此圖片”如何删除

管理系统-ITclub(中)

Stm32cubeide1.9.0\stm32cubemx 6.5 f429igt6 plus lan8720a, configure eth+lwip

MYSQL和MongoDB的分析

Go from introduction to practice - Interface (notes)

语言弱点列表--CWE,一个值得学习的网站
![[LeetCode]动态规划解分割数组II[Arctic Fox]](/img/a1/4644206db3e14c81f9f64e4da046bf.png)
[LeetCode]动态规划解分割数组II[Arctic Fox]
![[leetcode] dynamic programming solution split integer i[silver fox]](/img/18/8dc8159037ec1262444db8899cde0c.png)
[leetcode] dynamic programming solution split integer i[silver fox]

Go从入门到实战——错误机制(笔记)
![\w和[A-Za-z0-9_],\d和[0-9]等价吗?](/img/96/2649c9cf95b06887b57fd8af2d41c2.png)
\w和[A-Za-z0-9_],\d和[0-9]等价吗?
随机推荐
北京邮电大学|用于成本和延迟敏感的虚拟网络功能放置和路由的多智能体深度强化学习
Test automatique de Test logiciel - test d'interface de l'introduction à la maîtrise, apprendre un peu chaque jour
GBase 8a V8版本节点替换期间通过并发数控制资源使用减少对系统影响的方法
Go from introduction to actual combat - context and task cancellation (notes)
Open source technology exchange - Introduction to Chengying, a one-stop fully automated operation and maintenance manager
【MySQL】数据库函数通关教程下篇(窗口函数专题)
鲜为人知的mysql导入数据
Method of reading file contents by Excel
[LeetCode]161. Edit distance of 1
[LeetCode]508. 出現次數最多的子樹元素和
The create database of gbase 8A takes a long time to query and is suspected to be stuck
[LeetCode]100. 相同的树
Array assignment
管理系统-ITclub(上)
[LeetCode]572. 另一棵树的子树
xpath
洛谷P5706 再分肥宅水
matlab查找某一行或者某一列在矩阵中的位置
石子合并问题分析
GBase 8a OLAP分析函数 cume_dist的使用样例