pytest文档53-命令行实时输出错误信息(pytest-instafail)
前言
pytest 运行全部用例的时候,在控制台会先显示用例的运行结果(.或F), 用例全部运行完成后最后把报错信息全部一起抛出到控制台。
这样我们每次都需要等用例运行结束,才知道为什么报错,不方便实时查看报错信息。
pytest-instafail 插件可以在运行用例的时候,需实时查看用例报错内容,这样方便跟踪问题。
--instafail
执行全部用例,报错内容等用例运行完成才显示出来
>pytest
============================= test session starts =============================
collected 11 items
test_s.py .. [ 18%]
test_t.py ... [ 45%]
test_x.py .F.F [ 81%]
test_y.py .. [100%]
================================== FAILURES ===================================
___________________________________ test_02 ___________________________________
def test_02():
a = "hello"
b = "hello world"
> assert a == b
E AssertionError: assert 'hello' == 'hello world'
E - hello
E + hello world
test_x.py:12: AssertionError
___________________________________ test_04 ___________________________________
def test_04():
a = "hello"
b = "hello world"
> assert a not in b
E AssertionError: assert 'hello' not in 'hello world'
E 'hello' is contained here:
E hello world
test_x.py:24: AssertionError
===================== 2 failed, 9 passed in 1.32 seconds ======================
当用例很多的时候,不方便我们查看具体哪个报错对应哪条用例,加上--instafail
参数,方便实时查看报错内容
>pytest --instafail
============================= test session starts =============================
collected 11 items
test_s.py .. [ 18%]
test_t.py ... [ 45%]
test_x.py .F
___________________________________ test_02 ___________________________________
def test_02():
a = "hello"
b = "hello world"
> assert a == b
E AssertionError: assert 'hello' == 'hello world'
E - hello
E + hello world
test_x.py:12: AssertionError
test_x.py .F
___________________________________ test_04 ___________________________________
def test_04():
a = "hello"
b = "hello world"
> assert a not in b
E AssertionError: assert 'hello' not in 'hello world'
E 'hello' is contained here:
E hello world
test_x.py:24: AssertionError
test_y.py .. [100%]
===================== 2 failed, 9 passed in 1.37 seconds ======================
结合--tb=line
参数,看起来更直观
>pytest --instafail --tb=line
============================= test session starts =============================
collected 11 items
test_s.py .. [ 18%]
test_t.py ... [ 45%]
test_x.py .F
D:\test_x.py:12: AssertionError: assert 'hello' == 'hello world'
test_x.py .F
D:\test_x.py:24: AssertionError: assert 'hello' not in 'hello world'
test_y.py .. [100%]
===================== 2 failed, 9 passed in 1.30 seconds ======================
pytest文档53-命令行实时输出错误信息(pytest-instafail)的更多相关文章
- pytest文档52-命令行参数--setup-show查看fixture的执行过程
前言 使用命令行运行 pytest 用例的时候,看不到 fixture 的执行过程. 如果我们想知道fixture的执行过程和先后顺序,可以加上 --setup-show 命令行参数,帮助查看 fix ...
- pytest文档49-命令行参数--tb的使用
前言 pytest 使用命令行执行用例的时候,有些用例执行失败的时候,屏幕上会出现一大堆的报错内容,不方便快速查看是哪些用例失败. --tb=style 参数可以设置报错的时候回溯打印内容,可以设置参 ...
- Scrapy 1.4 文档 05 命令行工具
在系统命令行中,使用 scrapy 命令可以创建工程或启动爬虫,它控制着 Scrapy 的行为,我们称之为 Scrapy 命令行工具(command-line tool)或 Scrapy 工具(Scr ...
- pytest文档28-重复执行用例(pytest-repeat)
前言 平常在做功能测试的时候,经常会遇到某个模块不稳定,偶然会出现一些bug,对于这种问题我们会针对此用例反复执行多次,最终复现出问题来. 自动化运行用例时候,也会出现偶然的bug,可以针对单个用例, ...
- pytest文档10-命令行传参
前言 命令行参数是根据命令行选项将不同的值传递给测试函数,比如平常在cmd执行"pytest --html=report.html",这里面的"--html=report ...
- pytest文档50-命令行参数--durations统计用例运行时间
前言 写完一个项目的自动化用例之后,发现有些用例运行较慢,影响整体的用例运行速度,于是领导说找出运行慢的那几个用例优化下. --durations 参数可以统计出每个用例运行的时间,对用例的时间做个排 ...
- 【Python】【自动化测试】【pytest】【常用命令行选项】
https://www.cnblogs.com/cnkemi/p/9989019.html http://www.cnblogs.com/cnkemi/p/10002788.html pytest 常 ...
- pytest文档7-pytest-html生成html报告
前言 pytest-HTML是一个插件,pytest用于生成测试结果的HTML报告.兼容Python 2.7,3.6 pytest-html 1.github上源码地址[https://github. ...
- Oracle 远程访问配置 在 Windows Forms 和 WPF 应用中使用 FontAwesome 图标 C#反序列化XML异常:在 XML文档(0, 0)中有一个错误“缺少根元素” C#[Win32&WinCE&WM]应用程序只能运行一个实例:MutexHelper Decimal类型截取保留N位小数向上取, Decimal类型截取保留N位小数并且不进行四舍五入操作
Oracle 远程访问配置 服务端配置 如果不想自己写,可以通过 Net Manager 来配置. 以下配置文件中的 localhost 改为 ip 地址,否则,远程不能访问. 1.网络监听配置 ...
随机推荐
- pyhton:time模块和datetime模块
一.time模块 1.相关定义: time模块时间的表达有3种,时间戳,时间元祖,格式化时间 #时间戳: print(time.time())#获取当前时间戳.时间戳的计算是1970纪元后经过的浮点秒 ...
- 一道JavaScript的二维数组求平均数的题
JavaScript中只支持一维数组,但是可以在数组中嵌套数组来创建二维以至于多维的数组.今天下午在看书时候,发现一道感觉比较有意思的题,就是js中如何求二维数组的列之和和行之和,现在就给大家分享下, ...
- 前端直传文件到aliyun OSS
<template> <div id="container"> <div class="img-item m-1 upload-file&q ...
- 时不时刷刷BOSS 看看技术需求
5.熟悉Java,熟悉spring,rose等常见的web开发框架优先. 岗位要求:1. 大学本科及以上学历,计算机软件相关专业毕业:2. 3年及以上Java及Web系统设计和开发经验:3. 扎实的数 ...
- session、闪现、请求扩展
session 除请求对象之外,还有一个session对象.它允许你在不同请求储存特定用户的信息.它是在Cookies的基础上实现的,并且对,Cookies进行密钥签名要使用会话,你需要设置一个密钥. ...
- 一文带你熟悉JAVA IO这个看似很高冷的菇凉
Java IO 是一个庞大的知识体系,很多人学着学着就会学懵了,包括我在内也是如此,所以本文将会从 Java 的 BIO 开始,一步一步深入学习,引出 JDK1.4 之后出现的 NIO 技术,对比 N ...
- 番外篇 - Linux环境准备
这是一个比较早的系列,最近发现一直没有更新... asp.net core跨平台,所以我们首先需要一个linux来验证,所以第一篇就是准备我们的环境 .netcore尝试在centos6. ...
- HYWZ 吴恩达-机器学习+神经网络反向传播
- 论文阅读笔记: Multi-Perspective Sentence Similarity Modeling with Convolution Neural Networks
论文概况 Multi-Perspective Sentence Similarity Modeling with Convolution Neural Networks是处理比较两个句子相似度的问题, ...
- CCNP:重发布及实验
重发布(又:重分布.重分发):一台设备同时运行于两个协议或两个进程,默认从两端学习到的路由条目不共享:重发布技术就是人为的进行共享. 一 满足: 1.必须存在ASBR --- 自治系统边界路由器-- ...