pytest allure生成测试报告

安装:pip install allure-pytest
官方文档:https://docs.qumeta.io
下载allure:https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.7.0/

image.png
import allure
import pytest

@pytest.fixture(scope="session")
def login():
    print('用例先登录')
@allure.step("步骤1:点xxx")
def step_1():
    print('111')

@allure.step("步骤2:点xxx")
def step_2():
    print('222')

@allure.feature("编辑页面")
class TestEditPage():
    "编辑页面"
    @allure.story("这是一个xxx的用例")
    def test_1(self,login):
        "用例描述:先登录,再去执行xxx"
        step_1()
        step_2()
        print("xxx")

    @allure.story("打开a页面")
    def test_2(self, login):
        "用例描述:先登录,再去执行yyy"
        print("yyy")

if __name__ == '__main__':
    #注意生成测试报告,必须在命令行执行
#pytest --alluredir ./reports test08.py
#allure serve ./reports 启动allure查看报告
    pytest.main(['--alluredir','./reports','test08.py'])
    pytest.main(['--alluredir','./reports','test08.py'])
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容