用主函数打开allure
import datetime
import os
import shutil
import allure
import pytest
@allure.epic("今天4.28")
@allure.feature("今天是4月25日")#模块名称
class Test_01():
@allure.story("这是测试01")
def test_11(self):
assert 1 + 1 == 2
print("这是测试1")
@allure.title("这是标题2")
@allure.step("王")
def test_02(self):
assert 2 + 2 != 5
print("相等的2222")
def test_03(self):
assert 3 + 3 !=5
print("不相等")
tt = datetime.datetime.now()
print(tt)
def test_04(self):
assert 3 ==3
def test_05(self):
assert 4 + 4 == 8
print("1410相等")
# def test_setDir(filepath):
# '''
# 如果文件夹不存在就创建,如果文件存在就清空!
# :param filepath:需要创建的文件夹路径
# :return:
# '''
# if not os.path.exists(filepath):
# os.mkdir(filepath)
# else:
# shutil.rmtree(filepath)
# os.mkdir(filepath)
if __name__ == '__main__':
# 主函数中执行
# pytest.main(['-s',"./test_allure.py", "--clean-alluredir", "./temp"])
# os.system('allure generate ./temp -o ./report --clean')
pytest.main(["./test_allure.py", "--alluredir", "./temp"])
os.system('allure generate ./temp -o ./report --clean')
本文来自博客园,作者:{IceSparks},转载请注明原文链接:https://www.cnblogs.com/IceSparks/p/16202642.html
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~