1.搭建allure环境:
前置条件:python、allure已经安装成功
然后安装allure-pytest:在cmd窗口输入 pip3 install allure-pytest
2.在python代码中添加allure注解:
@allure.epic("我的测试报告")
@allure.feature("环境搭建")
@allure.severity(allure.severity_level.TRIVIAL)
class TestDemo(object):
@allure.story("用例1")
@allure.description("demo1")
def test_demo1(self):
3.在代码目录中新建一个存放allure报告的包:

在pycharm Terminal窗口运行用例:
pytes-------------运行所有的用例
allure serve D:/work/pythonCode/interfaceAutoTest/allure-results -----生成报告

运行结果:

原文:https://www.cnblogs.com/jina1121/p/15149308.html