Pytest allure基础用法

学习网站:

https://docs.qameta.io/allure/#_pytest

Feature & Story & step &Title的用法:

运行:

pytest test_demo.py --alluredir ./result

//py文件为运行文件  result为放报告的地址

allure serve ./result

//处理报告并在网站展示

@allure.feature("搜索模块")
class TestSearch():
    @allure.story("搜索成功")
    @allure.title("搜索用例1")
    def test_case_1(self):
        with allure.step("打开主界面"):
            print("step 1")
        with allure.step("打开登录界面"):
            assert 1==2
            print("step 2")
        with allure.step("输入信息"):
            print("step 3")
        with allure.step("点击登录"):
            print("step 4")

    @allure.story("搜索成功")
    @allure.title("搜索用例2")
    def test_case_2(self):
        print("搜索用例2")
    @allure.story("搜索失败")
    @allure.title("搜索用例3")
    def test_case_3(self):
        print("搜索用例3")

@allure.feature("登录模块")
class TestLogin():
    @allure.story("登录成功")
    @allure.title("登录用例1")
    def test_case_1(self):
        print("登录用例1")

    @allure.story("登录成功")
    @allure.title("登录用例2")
    def test_case_2(self):
        print("登录用例2")
    @allure.story("登录失败")
    @allure.title("登录用例3")
    def test_case_3(self):
        print("登录用例3")

posted @ 2022-05-13 16:04  lms21  阅读(64)  评论(0)    收藏  举报