打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
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的使用基本上就是这些了
2020年第二期《python接口自动化+测试开发》课程,12月15号开学!

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
Allure测试报告完整学习笔记
超详细的 pytest 教程 (四) 之测试报告篇
Python Requests Pytest YAML Allure实现接口自动化
Python、Pytest、Allure、Playwright和Jenkins实现测试自动化集成示例
pytest---fixture中conftest.py文件
pytest系列(三) - fixture 的多样玩法
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服