当前位置:网站首页>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
边栏推荐
- sql刷题584. 寻找用户推荐人
- Tutorial on principles and applications of database system (006) -- compiling and installing MySQL 5.7 (Linux Environment)
- Flux d'entrées / sorties et opérations de fichiers en langage C
- How to use etcd to realize distributed /etc directory
- Bugku's file contains
- VMware virtual machine failed during startup: VMware Workstation is incompatible with hyper-v
- SQL question brushing 584 Looking for user references
- Concatenate strings to get the result with the smallest dictionary order
- sql刷题627. 变更性别
- 【flask入门系列】Cookie与Session
猜你喜欢
C語言輸入/輸出流和文件操作
想做软件测试的女孩子看这里
How to restore the system with one click on Lenovo laptop
SQL question brushing 1050 Actors and directors who have worked together at least three times
Leetcode 77 combination -- backtracking method
软件工程导论——第六章——详细设计
Alibaba cloud, Zhuoyi technology beach grabbing dialogue AI
【直播预约】数据库OBCP认证全面升级公开课
VMware 虛擬機啟動時出現故障:VMware Workstation 與 Hyper-v 不兼容...
Stegano in the world of attack and defense
随机推荐
How to solve the problem that the battery icon of notebook computer does not display
Judge whether a binary tree is a balanced binary tree
Défaillance lors du démarrage de la machine virtuelle VMware: le poste de travail VMware n'est pas compatible avec hyper - V...
SQL question brushing 627 Change gender
Redis 分布式鎖
How wild are hackers' ways of making money? CTF reverse entry Guide
How does go use symmetric encryption?
Computed property “xxx“ was assigned to but it has no setter.
Virtual serial port simulator and serial port debugging assistant tutorial "suggestions collection"
Rhcsa Road
China nylon 11 industry research and future forecast report (2022 Edition)
Why is the pkg/errors tripartite library more recommended for go language error handling?
【PyG】文档总结以及项目经验(持续更新
【C语言基础】12 字符串
The difference between the lazy mode of singleton mode and the evil mode
C語言輸入/輸出流和文件操作
Flux d'entrées / sorties et opérations de fichiers en langage C
sql刷题586. 订单最多的客户
Gaussdb (for MySQL):partial result cache, which accelerates the operator by caching intermediate results
Sword finger offer II 015 All modifiers in the string