当前位置:网站首页>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
边栏推荐
- 如何使用 etcd 实现分布式 /etc 目录
- How to use etcd to realize distributed /etc directory
- Research and investment strategy report of China's sodium sulfate industry (2022 Edition)
- Comprehensively view the value of enterprise digital transformation
- Redis Distributed Lock
- Girls who want to do software testing look here
- Basic usage of Frida
- Rhcsa Road
- Hi Fun Summer, play SQL planner with starrocks!
- GaussDB(for MySQL) :Partial Result Cache,通过缓存中间结果对算子进行加速
猜你喜欢

你还在用收费的文档管理工具?我这有更牛逼的选择!完全免费

How to solve the problem that the battery icon of notebook computer does not display

Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers

数据库系统原理与应用教程(004)—— MySQL 安装与配置:重置 MySQL 登录密码(windows 环境)

How to repair the laptop that cannot connect to the wireless network

阿里云、追一科技抢滩对话式AI

为国产数据库添砖加瓦,StoneDB 一体化实时 HTAP 数据库正式开源!

SystemVerilog structure (II)

Introduction to software engineering - Chapter 6 - detailed design

Machine learning 11 clustering, outlier discrimination
随机推荐
SystemVerilog structure (II)
求求你们,别再刷 Star 了!这跟“爱国”没关系!
C語言輸入/輸出流和文件操作
[jetsonnano] [tutorial] [introductory series] [III] build tensorflow environment
SQL question brushing 584 Looking for user references
Rhcsa Road
Principes et applications du système de base de données (006) - - compilation et installation de MySQL 5.7 (environnement Linux)
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
Jojogan practice
How to restore the system of Sony laptop
China BMS battery management system Market Research Report (2022 Edition)
[flask introduction series] cookies and session
游戏行业安全选择游戏盾,效果怎么样?
Exclusive news: Alibaba cloud quietly launched RPA cloud computer and has opened cooperation with many RPA manufacturers
C language input / output stream and file operation
SystemVerilog-结构体(二)
Red team Chapter 10: ColdFusion the difficult process of deserializing WAF to exp to get the target
Today, at 14:00, 15 ICLR speakers from Hong Kong University, Beihang, Yale, Tsinghua University, Canada, etc. continue!
What is the digital transformation of manufacturing industry
FPN network details