当前位置:网站首页>Allure环境部署与生成+Allure内容增强
Allure环境部署与生成+Allure内容增强
2022-07-29 23:05:00 【司小幽】
1.Allure配置与入门
2.自动化用例与功能关联
1.功能用例
conftest.py
import pytest
@pytest.fixture(autouse = True)
def fix():
print("用例准备工作")
2.自动化用例
# 这不是用例函数,只是普通函数
import os
import allure
import pytest
@allure.step("步骤1:登录")
def step_1():
print("点击登录")
@allure.step("步骤2:输入用户名密码")
def step_2():
print("输入用户名密码")
@allure.feature("编辑分类文章")
# 测试类和测试用例
class TestEditPage():
# 测试用例
@allure.story("文章编辑")
@allure.title("编辑文章分类,重复保存,保存失败")
@allure.issue("http://127.0.0.1:8080/zentao/buge-login.html") #禅道系统的地址
@allure.testcase("http://127.0.0.1:8080/zentao/testcase-login.html") #禅道测试用例的地址
def test_1(self):
""" 编辑文章分类,重复保存,保存失败 前置条件: 1.登录 步骤: 1.编辑文章分类,输入文章类别,如计算机 2 点击保存按钮 3.重新打开编辑页面,输入:计算机 4.再次点击保存按钮 预期结果: 1.输入成功 2.保存成功 3.输入成功 4.保存失败,提示:已存在 :return: """
step_1()
step_2()
print("执行登录")
def test_2(self):
print("查询商品")
if __name__ == '__main__':
# pytest.main(['-vs'])
pytest.main(['--alluredir','./result'])
# 执行命令行的命令
# os.system('allure generate ./life -o ./report')
# 这个clean没有清理任何内容,只是允许你重复使用同一个目录生成报告,数据都会保留
os.system('allure generate ./result -o ./report --clean')
3.用例等级设置
""" 用例等级 allure对用例的等级划分成五个等级: blocker 阻塞缺陷(功能未实现,无法下一步) critical 严重缺陷(功能点缺失) normal 一般缺陷(边界情况,格式错误)默认等级 minor 次要缺陷(界面错误与ui需求不符) trivial 轻微缺陷(必须项无提示,或者提示不规范) """
import os
import allure
import pytest
@allure.severity('normal')
def test_case01():
print("测试用例一")
@allure.severity('critical')
def test_case02():
print("测试用例二")
@allure.severity('blocker')
def test_case03():
print("测试用例三")
def test_case04():
print("测试用例四")
def test_case05():
print("测试用例五")
def test_case06():
print("测试用例六")
def test_case01():
print("测试用例一")
if __name__ == '__main__':
# pytest.main(['--alluredir','./result'])
# 如果有很多用例,现在想快速的回顾,只执行用例等级为blocker和critical的用例
pytest.main(['--alluredir','./result','--allure-severities','blocker,critical','--clean-alluredir'])
os.system('allure serve result')
4.Allure用例描述详解
conftest.py
import pytest
@pytest.fixture(autouse = True)
def fix():
print("用例准备工作")
# 这不是用例函数,只是普通函数
import os
import allure
import pytest
@allure.step("步骤1:登录")
def step_1():
print("点击登录")
@allure.step("步骤2:输入用户名密码")
def step_2():
print("输入用户名密码")
@allure.epic("CRM后台系统: UI自动化")
@allure.feature("编辑分类文章")
# 测试类和测试用例
class TestEditPage():
# 测试用例
@allure.story("文章编辑")
@allure.title("编辑文章分类,重复保存,保存失败")
@allure.issue("http://127.0.0.1:8080/zentao/buge-login.html") #禅道系统的地址
@allure.testcase("http://127.0.0.1:8080/zentao/testcase-login.html") #禅道测试用例的地址
@allure.severity("critical")
def test_1(self):
""" 编辑文章分类,重复保存,保存失败 前置条件: 1.登录 步骤: 1.编辑文章分类,输入文章类别,如计算机 2 点击保存按钮 3.重新打开编辑页面,输入:计算机 4.再次点击保存按钮 预期结果: 1.输入成功 2.保存成功 3.输入成功 4.保存失败,提示:已存在 :return: """
step_1()
step_2()
print("执行登录")
@allure.story("商品查询")
@allure.title("查询可用的商品")
def test_2(self):
print("查询商品")
@allure.epic("CRM后台系统: UI自动化")
@allure.feature("人员管理")
class TestCase02:
@allure.story("测试场景二")
def test_case_3(self):
""" 用例标题 步骤 预期结果 :return: """
step_1()
if __name__ == '__main__':
# pytest.main(['-vs'])
pytest.main(['--alluredir','./result'])
# 执行命令行的命令
# os.system('allure generate ./life -o ./report')
# 这个clean没有清理任何内容,只是允许你重复使用同一个目录生成报告,数据都会保留
os.system('allure generate ./result -o ./report --clean')
5.Allure添加用例步骤描述详解
import os
import allure
import pytest
from class34.pytest_allure_step.case02.common_function_07 import *
@pytest.fixture()
def login_fix():
with allure.step("setup:登录"):
login("zz","123456")
@allure.feature("购物模块")
@allure.title("测试购物流程")
def test_shopping(login_fix):
""" 用例步骤: `1.登录 2.浏览商品 3.添加购物车 4.生成订单 5.支付成功 :param login_fix: :return: """
with allure.step("浏览商品"):
open_goods()
with allure.step("嵌套步骤"):
add_cart()
with allure.step("添加购物车"):
add_cart()
assert 1 == 2
with allure.step("购买商品"):
buy_goods()
with allure.step("支付"):
pay_goods()
if __name__ == '__main__':
pytest.main(['--alluredir', './result'])
os.system('allure generate ./result -o ./report --clean')
import allure
@allure.step("登录")
def login(username,password):
"""登录"""
print("前置操作:先登录")
@allure.step("浏览商品")
def open_goods():
"""浏览商品"""
with allure.step("步骤1:选择颜色"):
pass
with allure.step("步骤2:选择大小"):
pass
print("浏览商品")
@allure.step("添加商品到购物车")
def add_cart(goods_id="10086"):
"""添加购物车"""
print("添加购物车")
@allure.step("生成订单")
def buy_goods():
"""生成订单"""
print("buy")
@allure.step("支付")
def pay_goods():
"""支付"""
print("支付")
import os
import allure
import pytest
from class34.pytest_allure_step.case02.common_function_07 import *
@pytest.fixture()
def login_fix():
with allure.step("setup:登录"):
login("zz","123456")
@allure.feature("购物模块")
@allure.title("测试购物流程")
def test_shopping(login_fix):
""" 用例步骤: `1.登录 2.浏览商品 3.添加购物车 4.生成订单 5.支付成功 :param login_fix: :return: """
open_goods()
add_cart()
buy_goods()
pay_goods()
if __name__ == '__main__':
pytest.main(['--alluredir', './result'])
os.system('allure generate ./result -o ./report --clean')
6.Other
conftest.py
import allure
import pytest
# @allure.step 放在@pytest.fixture上面不行,放在下面可以
# @allure.step("登录的前置操作")
# @pytest.fixture
# def fix():
# print("登录")
# @allure.step直接用在fix上是不生效的
@allure.step("登录的前置操作")
@pytest.fixture
def fix1():
with allure.step("登录的前置操作"):
print("登录")
@pytest.fixture
@allure.step("登录的前置操作")
def fix2():
print("登录")
import os
import pytest
def test_case(fix1,fix2,fix3):
print("测试用例一")
if __name__ == '__main__':
pytest.main(['--alluredir', './result'])
os.system('allure generate ./result -o ./report --clean')
边栏推荐
- Professor Lu Shouqun from COPU was invited to give a speech at ApacheCon Asia
- 437. 路径总和 III ●●
- In 2022, the latest Gansu construction staff (material staff) mock exam questions and answers
- How to make labview an application (labview program recognizes shapes)
- 超分之RVRT
- DNA脱氧核糖核酸修饰石墨粉末|DNA修饰还原石墨烯功能材料|保存温度
- 【2023校招刷题】常见面试问题总结(七、常见总线协议篇)(随后续面试不断更新....)
- JetsonNano learning (5) JetsonNano installs PyTorch and Torchvision
- 通过 FileUploader 的初始化,了解 SAP UI5 应用的 StaticArea 初始化逻辑
- NetWorker Knowledge Corner|Easy to get an offer [Networker Interview Questions] What is the difference between a Layer 3 switch and a router?
猜你喜欢

Foxmail是什么邮箱?

DNA修饰纳米金颗粒|DNA脱氧核糖核酸偶联修饰碳纳米材料|实验原理

MySQL面试题:用户金额充值面试题详解

Super RVRT

This article penetrates the architecture design and cluster construction of the distributed storage system Ceph (hands-on)

Redis和MySQL如何保持数据一致性

Any to Any 实时变声的实现与落地丨RTC Dev Meetup

【C语言】链表详解(无头单向非循环)

The Sandbox Partners with Gravity to Bring RO Ragnarok to the Metaverse

线上无序的
随机推荐
MySQL面试题:用户金额充值面试题详解
MQTT over QUIC: The Next-Generation IoT Standard Protocol Brings New Impetus to Messaging Scenarios
高数下|三重积分习题课|高数叔|手写笔记
How to make labview an application (labview program recognizes shapes)
r‘w‘r‘w‘r‘w‘r
流水线上的农民:我在工厂种蔬菜
浅析即时通讯移动端开发DNS域名劫持等杂症
[2023 School Recruitment Questions] Summary of Common Interview Questions (7. Common Bus Protocols) (Continuously updated with subsequent interviews....)
J9数字论:为什么我们需要Web3?
Codeforces Round #245 (Div. 1) A (dfs)
设计消息队列存储消息的MySQL表格
Huawei 14 Days - (3) Kernel Development
[C] list explanation (headless ChanXiangFei cycle)
Implementation and implementation of Any to Any real-time voice change丨RTC Dev Meetup
kaniko --customPlatform parameter: support image construction of different platforms (eg: arm, etc.)
《MySQL DBA封神打怪之路》专栏学习大纲
Win7x64中使用PowerDesigner连接Oralce数据库报“[Oracle][ODBC][Ora]ORA-12154:TNS:无法解析指定的连接标识符”错误解决方法
华为14天-(3)内核开发
kaniko --customPlatform参数:支持不同平台的镜像构建(如:arm等)
信用卡又一新规来袭!菊风用科技助推金融行业提升服务质效