pytest+allure 入门

使用allure如何生成自动化测试报​​​​​​告 ?一文详解allure的使用 。_allure测试报告-CSDN博客

例子:

复制代码
import allure
import pytest
import os


@allure.epic("闹钟")
@allure.feature("闹钟增删")
class TestSchedule():

    def setup_class(self):
        print("清理测试数据--------删除所有闹钟")


    @allure.story("添加闹钟:响铃一次、循环闹钟")
    @pytest.mark.dependency(name='add_schedule')  # 命名为add_schedule,其他用例依赖他
    def test_add_schedule(self):
        pytest.assume("00000" == "00000")

    @allure.story("添加重复闹钟")
    @allure.title("测试添加重复闹钟")
    @allure.description("预期结果:测试添加重复闹钟fail")
    @pytest.mark.dependency(depends=['add_schedule'])
    def test_add_same_schedule(self):
        pytest.assume("00000" == "1111")

    @allure.story("查询-删除闹钟")
    @allure.title("测试查询-删除闹钟")
    @allure.description("预期结果:测试查询-删除闹钟success")
    @pytest.mark.dependency(depends=['add_schedule'])
    def test_query_del_schedule(self):
        with allure.step("查询闹钟"):
            pytest.assume("00000" == "00000")

        # 删除闹钟
        with allure.step("删除闹钟"):
            pytest.assume("00000" == "00000")

    @allure.story("语音添加闹钟")
    def test_add_schedule_nlp(self):
        pytest.assume("00000" == "00000")

@allure.epic("闹钟")
@allure.feature("闹钟音量")
class TestScheduleVolume():
    # X30特有功能
    @allure.story("闹钟音量调节")
    def test_schedule_volume(self):
        pytest.assume("00000" == "00000")


if __name__ == "__main__":
    pytest.main(["./test5.py", "-s", "-v", "--alluredir=./results/data", "--clean-alluredir"])
    os.system('allure generate ./results/data/ -o ./results/report --clean')
    os.system('allure open -h 127.0.0.1 -p 8883 ./results/report')
相关推荐
St_rive1 天前
Pytest skip&&skipif跳过⽤例
运维·服务器·pytest
努力搬砖的咸鱼4 天前
AI Agent测试全景图:它到底改变了什么
人工智能·python·ai·集成测试·pytest·agent·ai编程
X1A0RAN5 天前
自动化流水线提效·微观篇:pytest 执行顺序优化
自动化·pytest
久久学姐13 天前
Python+Playwright+Pytest+BDD,用FSM打造高效测试框架
python·pytest·bdd·playwright·fsm
小白上线*^_^*13 天前
Pytest 自动化测试框架速通指南(二)
软件测试·pytest·python测试框架·ai测试基础
Logintern0914 天前
pytest的AST 断言重写
pytest
Tinyfacture15 天前
接口自动化之添加商品(pytest)
python·测试工具·自动化·pytest
ji_shuke17 天前
从零深入:基于 Playwright + Pytest + Allure 的企业级 Web 端到端自动化测试框架实战
前端·自动化测试·docker·jenkins·pytest·allure·playwright
祉猷并茂,雯华若锦18 天前
Selenium+Pytest自动化测试框架实战
selenium·测试工具·pytest
祉猷并茂,雯华若锦20 天前
Pytest+Selenium自动化测试:失败自动截图集成Allure报告
selenium·测试工具·pytest