当前位置:网站首页>Pytest learning notes (13) -allure of allure Description () and @allure title()
Pytest learning notes (13) -allure of allure Description () and @allure title()
2022-07-01 16:53:00 【_ Li Sheng】
allure.description() and @allure.title()
Preface
Previously, I introduced allure Of step and attach function , Let's take a look this time allure The other two features of :
- @allure.description()
- @allure.title()
@allure.description()
- Add a detailed description for the test case , And show it in the test report , It can improve the readability of the test report , Make the report more intuitive , Easy to understand
grammar
There are three main grammars , as follows :
- Use under test cases ""“xxxx”"" Add description ( Add a general description - Method 1)
- Use @allure.description() Decorator ( Add a general description - Method 2)
- Use @allure.description_html() Decorator , add to HTML describe ( add to HTML Description and attach The decorator is used in the same way )
Code
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
""" __File__ = test_03.py __Project__= _JAuto-Interface __Time__ = 2022-02-15 18:37:36 __Author__ = Li Sheng """
import allure
@allure.description_html(""" <h1> Some features of test cases HTML describe </h1> <table style="width:100%"> <tr> <th>Firstname</th> <th>Lastname</th> <th>Age</th> </tr> <tr align="center"> <td>William</td> <td>Smith</td> <td>50</td> </tr> <tr align="center"> <td>Vasya</td> <td>Jackson</td> <td>94</td> </tr> </table> """)
def test_html_description():
assert True
@allure.description(""" Multi line test instructions Use allure.description Decorator . Nothing special """)
def test_description_from_decorator():
assert 42 == int(6 * 7)
def test_unicode_in_docstring_description():
"""Unicode describe . Этот тест проверяет юникод. Hello, man . """
assert 42 == int(6 * 7)
The results are as follows :


@allure.title()
- It can make the test case title more readable ( Can be Chinese characters )
- You can talk to Parameterize Parameterization and fixture Use a combination of
- usage :@allure.title(“msg”)
Code
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
""" __File__ = test_04.py __Project__= _JAuto-Interface __Time__ = 2022-02-15 19:37:59 __Author__ = Li Sheng """
import allure
import pytest
@allure.title(" Custom title ")
def test_with_a_title():
assert 2 + 2 == 4
@allure.title(" This test has a with unicode Custom title :Привет!")
def test_with_unicode_title():
assert 3 + 3 == 6
@allure.title(" Titles used in conjunction with parameterization : adding {param1} with {param2}")
@pytest.mark.parametrize('param1,param2,expected', [
(2, 2, 4),
(1, 2, 5)
])
def test_with_parameterized_title(param1, param2, expected):
assert param1 + param2 == expected
The results are as follows 

Summarize and contrast

Don't use allure.title() Decorator , By default, the report shows the use case function name , Poor readability , So I suggest you use more when writing use cases title Such small features , Make the test report more intuitive , It is convenient for collaborative students such as R & D to consult
边栏推荐
- SystemVerilog-结构体(二)
- [jetsonnano] [tutorial] [introductory series] [III] build tensorflow environment
- 挖财学堂班主任给的证券账户安全吗?能开户吗?
- Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
- How to maintain the laptop battery
- Template Engine Velocity Foundation
- How to restore the system with one click on Lenovo laptop
- sql刷题586. 订单最多的客户
- EndeavourOS移动硬盘安装
- Redis6.0 新功能
猜你喜欢

今天14:00 | 港大、北航、耶鲁、清华、加大等15位ICLR一作讲者精彩继续!

Building blocks for domestic databases, stonedb integrated real-time HTAP database is officially open source!

Soft test network engineer full truth simulation question (including answer and analysis)
![[flask introduction series] cookies and session](/img/2e/d50e0a032c4ec48935cb5df206a29b.png)
[flask introduction series] cookies and session

SystemVerilog-结构体(二)

VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...

Tutorial on principles and applications of database system (004) -- MySQL installation and configuration: resetting MySQL login password (Windows Environment)

sql刷题586. 订单最多的客户

PR basic clip operation / video export operation

【PyG】文档总结以及项目经验(持续更新
随机推荐
Origin2018 installation and use (sorting)
免费抽奖 | 《阿巴豆》探索未来系列盲盒数字版权作品全网首发!
P2592 [zjoi2008] birthday party (DP)
Determine whether the linked list is a palindrome linked list
Red team Chapter 10: ColdFusion the difficult process of deserializing WAF to exp to get the target
【Try to Hack】vulnhub DC4
数据库系统原理与应用教程(004)—— MySQL 安装与配置:重置 MySQL 登录密码(windows 环境)
Judge whether a binary tree is a balanced binary tree
Tutorial on the principle and application of database system (003) -- MySQL installation and configuration: manually configure MySQL (Windows Environment)
Report on Market Research and investment prospects of ammonium dihydrogen phosphate industry in China (2022 Edition)
Redis 分布式鎖
Template Engine Velocity Foundation
P2893 [USACO08FEB] Making the Grade G(dp&优先队列)
数据库系统原理与应用教程(003)—— MySQL 安装与配置:手工配置 MySQL(windows 环境)
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
Research and investment strategy report of hydroxypropyl beta cyclodextrin industry in China (2022 Edition)
机器学习11-聚类,孤立点判别
博睿数据一体化智能可观测平台入选中国信通院2022年“云原生产品名录”
阿里云、追一科技抢滩对话式AI
Hi Fun Summer, play SQL planner with starrocks!