pytest+allure开始使用

1、准备工作

安装pytest

pip install pytest

安装allure-pytest

pip install allure-pytest

安装allure

下载地址https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/,选择相应版本进行下载,解压后配置环境变量

2、开始使用

test_01.py

import pytest
import os

def func_1(a, b):
    return a + b


class TestClass:

    def setup_class(self):
        print("setup class start ......")

    def setup(self):
        print("setup start ......")

    def test_001(self):
        r = func_1(1, 2)
        assert r == 3

    def test_002(self):
        r = func_1(2, 2)
        assert r == 3

    def test_003(self):
        r = func_1(3, 2)
        assert r == 3

    def teardown(self):
        print("tear down ......")


if __name__ == "__main__":
    pytest.main(["--alluredir", "./report/result", "test_01.py"])
    os.system("allure generate ./report/result -o ./report/html --clean")

运行即可

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容