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 Day2
服务器·学习·pytest
chao_7892 天前
pytest 实战演练【pytest】
自动化测试·单元测试·自动化·pytest
qq_513728043 天前
为什么选择 pytest 而不是 unittest
pytest
思则变3 天前
[Pytest][Part 5]单条测试和用例集测试
pytest
杨梅树5 天前
pytest中mark的使用
pytest
测试开发技术7 天前
如何在 Pytest 中调用其他用例返回的接口参数?
面试·自动化·pytest·接口·接口测试·api测试
思则变8 天前
[Pytest][Part 4]多种测试运行方式
pytest
程序员三藏8 天前
如何使用Pytest进行测试?
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
一个处女座的测试10 天前
Python语言+pytest框架+allure报告+log日志+yaml文件+mysql断言实现接口自动化框架
python·mysql·pytest
思则变13 天前
[Pytest][Part 1]Pytest 自动化测试框架
pytest