pytest文档32-allure描述用例详细讲解
前言
pytest+allure是最完美的结合了,关于allure的使用,本篇做一个总结。
allure报告可以很多详细的信息描述测试用例,包括epic、feature、story、title、issue、testcase、severity等
环境准备
- python 3.6
- pytest 4.5.0
- allure-pytest 2.8.6
allure用例描述
| 使用方法 | 参数值 | 参数说明 |
|---|---|---|
| @allure.epic() | epic描述 | 敏捷里面的概念,定义史诗,往下是feature |
| @allure.feature() | 模块名称 | 功能点的描述,往下是story |
| @allure.story() | 用户故事 | 用户故事,往下是title |
| @allure.title(用例的标题) | 用例的标题 | 重命名html报告名称 |
| @allure.testcase() | 测试用例的链接地址 | 对应功能测试用例系统里面的case |
| @allure.issue() | 缺陷 | 对应缺陷管理系统里面的链接 |
| @allure.description() | 用例描述 | 测试用例的描述 |
| @allure.step() | 操作步骤 | 测试用例的步骤 |
| @allure.severity() | 用例等级 | blocker,critical,normal,minor,trivial |
| @allure.link() | 链接 | 定义一个链接,在测试报告展现 |
| @allure.attachment() | 附件 | 报告添加附件 |
测试案例
pytest结合allure测试用例
import pytest
import allure
# 作者:上海-悠悠 qq交流群:874033608
@pytest.fixture(scope="session")
def login_fixture():
print("前置条件:登录")
@allure.step("步骤1")
def step_1():
print("操作步骤---------------1")
@allure.step("步骤2")
def step_2():
print("操作步骤---------------2")
@allure.step("步骤3")
def step_3():
print("操作步骤---------------3")
@allure.epic("epic对大Story的一个描述性标签")
@allure.feature("测试模块")
class TestDemoAllure():
@allure.testcase("http://49.235.x.x:8080/zentao/testcase-view-6-1.html")
@allure.issue("http://49.235.x.x:8080/zentao/bug-view-1.html")
@allure.title("用例的标题")
@allure.story("用户故事:1")
@allure.severity("critical")
def test_case_1(self, login_fixture):
'''case description:作者:上海-悠悠 qq交流群:874033608
1.点文章分类导航标签 -跳转编辑页面
2.编辑页面输入,分类名称,如:上海-悠悠-可以输入
3.点保存按钮保存成功
'''
step_1()
step_2()
@allure.story("用户故事:2")
def test_case_2(self, login_fixture):
print("测试用例1")
step_1()
step_3()
@allure.epic("epic对大Story的一个描述性标签")
@allure.feature("模块2")
class TestDemo2():
@allure.story("用户故事:3")
def test_case_3(self, login_fixture):
print("测试用例1")
step_1()
@allure.story("用户故事:4")
def test_case_4(self, login_fixture):
print("测试用例1")
step_3()
报告展示
cd到用例目录执行用例生成allure报告
pytest --alluredir ./report/allure
allure serve ./report/allure
报告展示内容

命令行参数
pytest运行用例的时候可以加上allure标记用例的参数
--allure-severities=SEVERITIES_SET
Comma-separated list of severity names. Tests only
with these severities will be run. Possible values
are: blocker, critical, normal, minor, trivial.
--allure-epics=EPICS_SET
Comma-separated list of epic names. Run tests that
have at least one of the specified feature labels.
--allure-features=FEATURES_SET
Comma-separated list of feature names. Run tests that
have at least one of the specified feature labels.
--allure-stories=STORIES_SET
Comma-separated list of story names. Run tests that
have at least one of the specified story labels.
--allure-link-pattern=LINK_TYPE:LINK_PATTERN
Url pattern for link type. Allows short links in test,
like 'issue-1'. Text will be formatted to full url
with python str.format().
选择运行你要执行epic的用例
pytest --alluredir ./report/allure --allure-epics=epic对大Story的一个描述性标签
选择运行你要执行features的用例
pytest --alluredir ./report/allure --allure-features=模块2
选择运行你要执行features的用例
pytest --alluredir ./report/allure --allure-stories="用户故事:1"
关于allure的使用基本上就是这些了
pytest文档32-allure描述用例详细讲解的更多相关文章
- 【自动化基础】allure描述用例详细讲解及实战
前言 allure可以输出非常精美的测试报告,也可以和pytest进行完美结合,不仅可以渲染页面,还可以控制用例的执行.下面就对allure的使用进行一个详细的介绍和总结. 需要准备的环境: pyth ...
- pytest文档3-pytest+Allure+jenkins+邮箱发送
前言: 虽然网上有很多邮件配置的文章,但还是想自己写一下配置的过程,因为在中间也碰到了不同坑.按照这个文档配置的话,99%都可以成功. 一.jenkins 配置邮箱 1.打开jenkins后进入点 ...
- pytest文档40-pytest.ini配置用例查找规则(面试题)
前言 面试题:pytest如何执行不是test开头的用例?如执行 xxx_*.py这种文件的用例. pytest.ini 配置文件可以修改用例的匹配规则. pytest命令行参数 cmd打开输入pyt ...
- pytest文档2-pytest+Allure+jenkins+邮箱发送
前言: 上一章节讲解了tomcat+jenkins的环境搭建,这一章节主要讲一下Allure报告在jenkins上的配置 步骤: 1.新建一个item 2.输入项目的名称,选择自由风格,点击保存 3. ...
- pytest文档28-重复执行用例(pytest-repeat)
前言 平常在做功能测试的时候,经常会遇到某个模块不稳定,偶然会出现一些bug,对于这种问题我们会针对此用例反复执行多次,最终复现出问题来. 自动化运行用例时候,也会出现偶然的bug,可以针对单个用例, ...
- pytest文档47-allure报告添加用例失败截图
前言 使用 selenium 做 web 自动化的时候,很多小伙伴希望用例失败的时候能截图,把异常截图展示到allure报告里面. pytest 有个很好的钩子函数 pytest_runtest_ma ...
- pytest文档33-Hooks函数获取用例执行结果(pytest_runtest_makereport)
前言 pytest提供的很多钩子(Hooks)方法方便我们对测试用例框架进行二次开发,可以根据自己的需求进行改造. 先学习下pytest_runtest_makereport这个钩子方法,可以更清晰的 ...
- pytest文档1-pytest+Allure+jenkins+邮箱发送
前言: 1.pytest+allure是目前很多公司使用较多的一种报告样式,因为它更详细,各种指标更直观(简单的说就是看着更高大上,更能装X). 环境准备: 1.Windows10 2.Allure ...
- pytest文档12-skip跳过用例
前言 pytest.mark.skip可以标记无法在某些平台上运行的测试功能,或者您希望失败的测试功能 skip意味着只有在满足某些条件时才希望测试通过,否则pytest应该跳过运行测试. 常见示例是 ...
随机推荐
- springIOC源码接口分析(二):ConfigurableBeanFactory
一 继承功能 1 SingletonBeanRegistry接口 此接口是针对Spring中的单例Bean设计的.提供了统一访问单例Bean的功能,类中定义了以下方法: 2 HierarchicalB ...
- 一文教你一次性完成Helm 3迁移
2019年,Kubernetes软件包管理器--Helm发布了最新版本Helm 3,并且该版本已经stable.Helm 3中的一些关键特性我们在之前的文章中已经介绍过,其中一些功能吸引了许多开发人员 ...
- 最新2.7版本丨DataPipeline数据融合产品最新版本发布
此次发布的2.7版本在进一步优化产品底层数据处理逻辑的同时更加注重提升用户在数据融合任务的日常管理.运行监控及资源分配等管理方面的功能增强与优化,力求帮助大家更为直观.便捷.稳定地管理数据融合任务,提 ...
- java工具类方法
1.生成16位数字(当时日期时间加随机两位数) public static String getNo16() { String getNo = getNo(); return getNo.substr ...
- 01背包与完全背包(dp复习)
01背包和完全背包都是dp入门的经典,我的dp学的十分的水,借此更新博客的机会回顾一下 01背包:给定总容量为maxv的背包,有n件物品,第i件物品的的体积为w[i],价值为v[i],问如何选取才能是 ...
- WeChall_Training: Programming 1 (Training, Coding)
When you visit this link you receive a message.Submit the same message back to http://www.wechall.ne ...
- cookie 笔记
Cookie “小甜点” Cookie的作用是与服务器进行交互,作为HTTP规范的一部分而存在 ,而Web Storage仅仅是为了在本地“存储”数据而生 用来记录:用户信息 计算机信息 浏 ...
- 【5min+】 巨大的争议?C# 8 中的接口
系列介绍 [五分钟的dotnet]是一个利用您的碎片化时间来学习和丰富.net知识的博文系列.它所包含了.net体系中可能会涉及到的方方面面,比如C#的小细节,AspnetCore,微服务中的.net ...
- ESXi以及WorkStation缩减thin provision模式Linux虚拟机磁盘的方法
1. 公司的服务器采用ESXi 进行管理. 有时候为了灵活性,需要将虚拟机从ESXi服务器上面导出来. 放置到不同的客户机器上面去. 2. 但是发现,比如我在linux里面安装了Oracle数据库, ...
- 高并发之——不得不说的线程池与ThreadPoolExecutor类浅析
一.抛砖引玉 既然Java中支持以多线程的方式来执行相应的任务,但为什么在JDK1.5中又提供了线程池技术呢?这个问题大家自行脑补,多动脑,肯定没坏处,哈哈哈... 说起Java中的线程池技术,在很多 ...