当前位置:网站首页>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
边栏推荐
- 数据库系统原理与应用教程(004)—— MySQL 安装与配置:重置 MySQL 登录密码(windows 环境)
- Rhcsa Road
- MySQL learning summary
- Soft test network engineer full truth simulation question (including answer and analysis)
- Judge whether the binary tree is a binary search tree
- VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...
- Determine whether the linked list is a palindrome linked list
- redis -- 数据类型及操作
- 数据库系统原理与应用教程(002)—— MySQL 安装与配置:MySQL 软件的卸载(windows 环境)
- Research and investment strategy report of neutral protease industry in China (2022 Edition)
猜你喜欢
![[JetsonNano] [教程] [入门系列] [三] 搭建TensorFlow环境](/img/0e/52e37527bc717c7a55741725087bad.png)
[JetsonNano] [教程] [入门系列] [三] 搭建TensorFlow环境

Comprehensively view the value of enterprise digital transformation

How to solve the keyboard key failure of notebook computer

Redis Distributed Lock

Babbitt | yuan universe daily must read: Naixue coin, Yuan universe paradise, virtual stock game Do you understand Naixue's tea's marketing campaign of "operation pull full"

【C语言基础】12 字符串

Template engine velocity Foundation

SQL question brushing 586 Customers with the most orders

Borui data integrated intelligent observable platform was selected into the "Yunyuan production catalogue" of China Academy of communications in 2022

Today, at 14:00, 15 ICLR speakers from Hong Kong University, Beihang, Yale, Tsinghua University, Canada, etc. continue!
随机推荐
数据库系统原理与应用教程(005)—— yum 离线安装 MySQL5.7(Linux 环境)
sql刷题627. 变更性别
FRP intranet penetration, reverse proxy
How to repair the laptop that cannot connect to the wireless network
Hi Fun Summer, play SQL planner with starrocks!
AI高考志愿填报:大厂神仙打架,考生付费围观
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
What are the differences between PHP and DW
【C补充】【字符串】按日期排序显示一个月的日程
Chinese diosgenin market forecast and investment strategy report (2022 Edition)
Mlperf training v2.0 list released, with the same GPU configuration, the performance of Baidu PaddlePaddle ranks first in the world
Jojogan practice
What is the effect of choosing game shield safely in the game industry?
Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...
Red team Chapter 10: ColdFusion the difficult process of deserializing WAF to exp to get the target
Buuctf gold III
[pyg] document summary and project experience (continuously updated
SystemVerilog-结构体(二)
Leetcode 216 combined summation III -- backtracking method
【PyG】文档总结以及项目经验(持续更新