美文网首页
pytest+allure开始使用

pytest+allure开始使用

作者: 深吸一口气 | 来源:发表于2021-09-09 14:03 被阅读0次

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")

运行即可

相关文章

网友评论

      本文标题:pytest+allure开始使用

      本文链接:https://www.haomeiwen.com/subject/waagwltx.html