pytest_runtest_makereport 获取pytest的测试结果和caseid
目的: 自动获取pytest case执行结果和caseid 存为变量,后续可以和case管理工具集成
@pytest.hookimpl(hookwrapper=True, tryfirst=True)
def pytest_runtest_makereport(item, call):
out = yield
print("Case result is: - ", out)
report = out.get_result()
if report.when == "call":
print("test report: %s" % report)
print("test step: %s" % report.when)
print("nodeid: %s" % report.nodeid)
# print("description is : %s" % str(item.function.__doc__))
print("execute result: %s" % report.outcome)
global Case_Result, Case_Name, Case_ID
case_result = (True if report.outcome == "passed" else False) # case执行结果转换成boolean 类型
Case_Result = case_result
case_name = report.nodeid.split("::")[-1] # 获取 testcase name, nodeid: testcase/SmartSharedList/test_SmartSharedList.py::Test_SmartSharedList::test_TC_13096_ARM4329_56789
case_id = case_name.split("_")[-3] # 获取caseID, test_TC_13096_ARM4329_56789
Case_Name = case_name
Case_ID = case_id
# Upload result to qtest through caseid and result
print("Upload result to qtest")
最新文章
- 【python】用setup安装自定义模块和包
- PHP常用功能
- 网站标题ico那些事
- [Asp.net]c#中的斜杠和反斜杠
- windows设置java环境变量
- Graph database_neo4j 底层存储结构分析(7)
- Leetcode: Lexicographical Numbers
- Sql中的union和union all的讲解
- oracle 存储过程编辑 卡死
- 达内TTS6.0课件oop_day02
- Xcode插件失效以后的处理方法
- ASP.net core 2.0.0 中 asp.net identity 2.0.0 的基本使用(三)—用户账户及cookie配置
- 论文笔记--PCN:Real-Time Rotation-Invariant Face Detection with Progressive Calibration Networks
- Do a web framework ourselves
- Nginx 如何设置反向代理 多服务器,配置区分开来,单独文件保存单个服务器 server 主机名配置,通过 include 实现
- CF747F Igor and Interesting Numbers
- _itemmod_extra_equipments_enable
- 关于scp在zsh报错:zsh:no matches found :
- Android 应用架构 - Google 推荐
- oracle查询锁表
热门文章
- 【javascript】slice()、substring()和substr() 三种字符串截取方法区别
- 【Linux SPI】RFID RC522 设备驱动
- javaWeb学习一
- 06 RDD编程
- 如何利用fooview实现钉钉自动打卡
- .net core 3.1项目运行在Windows server 2012R2服务器上,Decimal类型小数点不见了,求解!32112.7958
- Bugku-不可破译的密码[wp]
- 自定义Ribbon负载均衡
- pychars的使用
- redis cluster 部署