当前位置: 首页 > news >正文

连云港网站制作公司哪家好线上营销渠道

连云港网站制作公司哪家好,线上营销渠道,政府门户网站建设,页面设计粉色好处目录: allure2报告中添加附件-图片 Allure2报告中添加附件Allure2报告中添加附件(图片)应用场景Allure2报告中添加附件(图片)-Python代码示例:allure2报告中添加附件-日志 Allure2报告中添加附件&#xff…

目录:

  1. allure2报告中添加附件-图片
    1. Allure2报告中添加附件
    2. Allure2报告中添加附件(图片)应用场景
    3. Allure2报告中添加附件(图片)-Python
    4. 代码示例:
  2. allure2报告中添加附件-日志
    1. Allure2报告中添加附件(日志)应用场景
    2. 代码示例:
  3. allure2报告中添加附件-html
    1. Allure2报告中添加附件(html)应用场景
    2. 语法:
    3. 代码示例:
  4. allure2报告中添加附件-视频
    1. Allure2报告中添加附件(视频)应用场景
    2. 语法:
    3. 代码示例:
    4. 终端运行:

1.allure2报告中添加附件-图片

Allure2 报告中添加附件
TEXT = ("text/plain", "txt")
CSV = ("text/csv", "csv")
TSV = ("text/tab-separated-values", "tsv")
URI_LIST = ("text/uri-list", "uri")HTML = ("text/html", "html")
XML = ("application/xml", "xml")
JSON = ("application/json", "json")
YAML = ("application/yaml", "yaml")
PCAP = ("application/vnd.tcpdump.pcap", "pcap")PNG = ("image/png", "png")
JPG = ("image/jpg", "jpg")
SVG = ("image/svg-xml", "svg")
GIF = ("image/gif", "gif")
BMP = ("image/bmp", "bmp")
TIFF = ("image/tiff", "tiff")MP4 = ("video/mp4", "mp4")
OGG = ("video/ogg", "ogg")
WEBM = ("video/webm", "webm")PDF = ("application/pdf", "pdf")
Allure2 报告中添加附件(图片)应用场景
  • 应用场景:在做 UI 自动化测试时,可以将页面截图,或者出错的页面进行截图,将截图添加到测试报告中展示,辅助定位问题。
  • 解决方案:
    • Python:使用 allure.attach 或者 allure.attach.file() 添加图片。
    • Java:直接通过注解或调用方法添加。
 Allure2 报告中添加附件(图片)- Python
  • 语法:allure.attach.file(source, name, attachment_type, extension),参数解释:
    • source:文件路径,相当于传一个文件。
    • name:附件名字。
    • attachment_type:附件类型,是 allure.attachment_type 其中的一种(支持 PNG、JPG、BMP、GIF 等)。
    • extension:附件的扩展名。
       
 代码示例:

test_order.py

import allureclass TestWithAttach:def test_pic(self):allure.attach.file('./img/111.jpg',name="这是一个图片",attachment_type=allure.attachment_type.JPG,extension="jpg")

终端运行:

 

 

 

  • 语法:allure.attach(body, name=None, attachment_type=None, extension=None):,参数解释:
    • body:要写入附件的内容
    • name:附件名字。
    • attachment_type:附件类型,是 allure.attachment_type 其中的一种(支持 PNG、JPG、BMP、GIF 等)。
    • extension:附件的扩展名。
       
import allureclass TestWithAttach:def test_pic2(self):with open("./img/111.jpg", mode="rb") as f:file = f.read()allure.attach(file, "页面截图", attachment_type=allure.attachment_type.JPG)

 终端运行:

 

2.allure2报告中添加附件-日志

Allure2 报告中添加附件(日志)应用场景
  • 应用场景:报告中添加详细的日志信息,有助于分析定位问题。
  • 解决方案:
    • Python:使用 python 自带的 logging 模块生成日志,日志会自动添加到测试报告中。
    • Java:直接通过注解或调用方法添加。
  • 日志配置,在测试报告中使用 logger 对象生成对应级别的日志。 
代码示例:

log_util.py

import logging
import osfrom logging.handlers import RotatingFileHandler# 绑定绑定句柄到logger对象
logger = logging.getLogger(__name__)
# 获取当前工具文件所在的路径
root_path = os.path.dirname(os.path.abspath(__file__))
# 拼接当前要输出日志的路径
log_dir_path = os.sep.join([root_path, f'/logs'])
if not os.path.isdir(log_dir_path):os.mkdir(log_dir_path)
# 创建日志记录器,指明日志保存路径,每个日志的大小,保存日志的上限
file_log_handler = RotatingFileHandler(os.sep.join([log_dir_path, 'log.log']), maxBytes=1024 * 1024, backupCount=10 , encoding="utf-8")
# 设置日志的格式
date_string = '%Y-%m-%d %H:%M:%S'
formatter = logging.Formatter('[%(asctime)s] [%(levelname)s] [%(filename)s]/[line: %(lineno)d]/[%(funcName)s] %(message)s ', date_string)
# 日志输出到控制台的句柄
stream_handler = logging.StreamHandler()
# 将日志记录器指定日志的格式
file_log_handler.setFormatter(formatter)
stream_handler.setFormatter(formatter)
# 为全局的日志工具对象添加日志记录器
# 绑定绑定句柄到logger对象
logger.addHandler(stream_handler)
logger.addHandler(file_log_handler)
# 设置日志输出级别
logger.setLevel(level=logging.INFO)

test_order.py 

import allure
from utils.log_util import logger@allure.epic("需求1")
@allure.feature("功能模块1")
class TestEpic:@allure.story("子功能1")@allure.title("用例1")def test_case1(self):logger.info('这是TestEpic 第一条用例')print("用例1")@allure.story("子功能2")@allure.title("用例2")def test_case2(self):logger.debug('这是TestEpic 第二条用例')print("用例2")@allure.story("子功能2")@allure.title("用例3")def test_case3(self):logger.warning('这是TestEpic 第三条用例')print("用例3")@allure.story("子功能1")@allure.title("用例4")def test_case4(self):logger.error('这是TestEpic 第四条用例')print("用例4")

终端运行:

 

 

 

日志展示在 Test body 标签下,标签下可展示多个子标签代表不同的日志输出渠道:

  • log 子标签:展示日志信息。
  • stdout 子标签:展示 print 信息。
  • stderr 子标签:展示终端输出的信息。

禁用日志,可以使用命令行参数控制 --allure-no-capture

 
pytest --alluredir ./results --clean-alluredir --allure-no-capture

 

3.allure2报告中添加附件-html

Allure2 报告中添加附件(html)应用场景
  • 应用场景:可以定制测试报告页面效果,可以将 HTML 类型的附件显示在报告页面上。
  • 解决方案:
    • Python:使用 allure.attach() 添加 html 代码。
    • Java:直接通过注解或调用方法添加。
语法:

allure.attach(body, name, attachment_type, extension),参数解释:

  • body:要写入附件的内容(HTML 代码块)。
  • name:附件名字。
  • attachment_type:附件类型,是 allure.attachment_type 其中的一种。
  • extension:附件的扩展名。
代码示例:
import allureclass TestWithAttach:def test_html(self):allure.attach('<head></head><body> a page </body>','附件是HTML类型',allure.attachment_type.HTML)def test_html_part(self):allure.attach('''html代码块''','附件是HTML类型',allure.attachment_type.HTML)

终端运行:

 

 

 

4.allure2报告中添加附件-视频

Allure2 报告中添加附件(视频)应用场景
  • 应用场景:在做 UI 自动化测试时,可以将页面截图,或者出错的页面进行截图,将截图添加到测试报告中展示,辅助定位问题。
  • 解决方案:
    • Python:使用 allure.attach.file() 添加视频。
    • Java:直接通过注解或调用方法添加。
语法:
  • allure.attach.file(source, name, attachment_type, extension),参数解释:
    • source:文件路径,相当于传一个文件。
    • name:附件名字。
    • attachment_type:附件类型,是 allure.attachment_type 其中的一种。
    • extension:附件的扩展名。
 代码示例:
import allureclass TestWithAttach:def test_video(self):allure.attach.file("./mp4/111.mp4",name="视频",attachment_type=allure.attachment_type.MP4,extension="mp4")
终端运行:

 

 

http://www.hotlads.com/news/1322.html

相关文章:

  • fireworks个人网站模板网络技术推广服务
  • 中国b2b网站大全市场营销策划案的范文
  • 重庆施工员证书查询官方网站seo案例分享
  • 网页设计代码书seo需求
  • 网站的视频怎么下载使用软件提高百度推广排名
  • 万户网络做网站怎么样长沙谷歌优化
  • 做百度网站如何收费免费网站模板库
  • 做网站 设备网站开通
  • 日本韩国澳大利亚出线seo排名优化课程
  • wordpress新闻网站模板武汉网络优化知名乐云seo
  • 河南新乡做网站公司今天特大军事新闻
  • 做民宿哪个网站好facebook海外推广
  • 手机网站开发视频教程福建seo快速排名优化
  • 珠海网站推广优化semseo
  • 网站开发技术流程上海网站快速优化排名
  • 合肥网上商城网站建设seo公司彼亿营销
  • 非模板网站郑州整站网站优化
  • 网站banner的设计要素小程序怎么引流推广
  • 小型公司建网站网络广告是什么
  • 网站建设可研推广技术
  • 四平网站公司佛山网站建设
  • 做珠宝b2b网站有哪些网络推广的公司更可靠
  • 企业融资的40种方式网站关键词排名优化工具
  • 重庆网站建设公司 十年爱用建站
  • h5网站建设+北京登封seo公司
  • 武汉建筑企业排名广州百度推广优化
  • 在线做海报网站如何做市场调研和分析
  • 没有病毒的软件下载网站百度seo快速提升排名
  • wordpress 运行广西seo优化
  • 地图网站怎么做的百度快照和广告的区别