https://dl.bintray.com/qameta/generic/io/qameta/allure/allure/2.7.0/
windows下载版本:
解压后添加到环境变量:
E:\Program Files\allure-2.7.0\allure-2.7.0\bin
代码:
#pytest生成测试报告
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 test1(self,login):
"""用例描述 先登录再执行story的用例"""
step_1()
step_2()
print("这是一个xxx的用例")
@allure.story("打开a页面")
def test2(self,login):
"""用例描述:先执行fixcure的登录然后再执行yyy"""
print("yyy")
if __name__ == '__main__':
#注意生成测试报告必须在命令行执行
# 所以执行时要切换到seelenium_projrct目录下去
#pytest --alluredir ./reports testcases/pytest/test08.py 生成测试报告存放到路径reports目录下
# 所以执行时要切换到seelenium_projrct目录下去
#allure serve ./reports 启动allure 查看报告
pytest.main(['--alluredir' './reports' 'test08.py'])
pytest.main(['--alluredir' './reports' 'test08.py'])
#注意生成测试报告必须在命令行执行
# 所以执行时要切换到seelenium_projrct目录下去
#pytest --alluredir ./reports testcases/pytest/test08.py 生成测试报告存放到路径reports目录下
# 所以执行时要切换到seelenium_projrct目录下去
#allure serve ./reports 启动allure 查看报告
C:\Users\Administrator\pythonxiangmu\seelenium_project>pytest --alluredir ./reports testcases/pytest/test08.py
执行结果;
C:\Users\Administrator\pythonxiangmu\seelenium_project>allure serve ./reports
执行结果: