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')
相关推荐
唐古乌梁海2 小时前
【pytest 】 pytest 生命周期
pytest
专职1 天前
pytest详细教程
开发语言·python·pytest
乄捷径1 天前
pytest入门到熟练
pytest
专职1 天前
pytest+requests+allure生成接口自动化测试报告
开发语言·python·pytest
小熊出擊2 天前
【pytest】fixture 内省(Introspection)测试上下文
python·单元测试·pytest
小熊出擊3 天前
【pytest】finalizer 执行顺序:FILO 原则
python·测试工具·单元测试·pytest
小熊出擊4 天前
【pytest】使用 marker 向 fixture 传递数据
python·pytest
wa的一声哭了4 天前
Deep Learning Optimizer | Adam、AdamW
人工智能·深度学习·神经网络·机器学习·自然语言处理·transformer·pytest
专职6 天前
pytest生成测试用例,allure生成测试报告
测试用例·pytest
小丁爱养花9 天前
接口自动化测试 - pytest [1]
python·自动化·pytest