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")
运行即可