一 配置使用allure
二 生成html报告
Report successfully generated to allure-report
(venv) D:\pyscript\tangseng\Interface_AutoTest\report>
三 代码
import requests
import yaml
import pytest
import allure
# @allure.step("类级别测试步骤")
@allure.feature("我是一级需求")
class Testclass():
@allure.story("二级需求1")
@allure.severity(allure.severity_level.CRITICAL)
def test01(self):
allure.attach("这是一个纯文本1",name="文本信息1",attachment_type=allure.attachment_type.TEXT)
print("in test01-1")
allure.attach("这是一个纯文本2", name="文本信息2", attachment_type=allure.attachment_type.TEXT)
print("in test01-2")
assert 1
@allure.story("二级需求2")
@allure.severity(allure.severity_level.CRITICAL)
def test02(self,f_module):
with allure.step("第一步"):
print("in test1")
allure.attach.file("./1.jpeg",name="图片",attachment_type=allure.attachment_type.JPG)
with allure.step("第二步"):
print("in test2")
with allure.step("第3步"):
print("in test3")
assert 1
@allure.story("二级需求1")
@allure.issue('https://www.sohu.com','bug名称')
@allure.testcase('www.baidu.com','测试用例名称')
@allure.link("www.qq.com",name="腾讯主页")
@allure.severity(allure.severity_level.CRITICAL)
@allure.title('新标题')
@allure.description("<font color='red'>描述第一行</font><Br/>描述第二行<Br/>描述第三行")
def test03(self):
allure.attach("<body>这是一个网页</body>", name="HTML测试模块", attachment_type=allure.attachment_type.HTML)
print("in test03")
assert 1
if __name__ == "__main__":
pytest.main()