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.网络监听配置 ...
随机推荐
- 2020重新出发,NOSQL,MongoDB分布式集群架构
MongoDB分布式集群架构 看到这里相信你已经掌握了 MongoDB 的大部分基本知识,现在在单机环境下操作 MongoDB 已经不存在问题,但是单机环境只适合学习和开发测试,在实际的生产环境中,M ...
- sudo提权,ansible批量给所有主机创建系统账户,授权
sudo(superuser or another do)让普通用户可以以超级管理员或其他人的身份执行命令. sudo基本流程如下: 1.管理员需要先授权(修改/etc/sudoers文件) 2.普通 ...
- xampp安装和使用:windows和linux使用安装微擎小程序
1.官网下载xampp XAMPP:Apache+MySQL+PHP+PERL,适用于windows+linux+macos x+Solaris等多系统使用 官网地址:https://www.apac ...
- visual studio项目多级引用不拷贝dll的问题
最近碰到一个visual studio项目多级引用不拷贝dll的问题,花了很久查了很多资料,特此记录 A项目引用B项目, B项目引用C项目,C项目引用ef及oracle.ef using Oracle ...
- JS中对获取一个标签的class的方法封一个库
在JS中我们经常会会用到,获取一个标签的id var aId=document.getElementById("id") 现在虽然有getElementsByClassName这个 ...
- Spring使用@Async实现异步
使用场景 在实际项目中,一个接口如果需要处理很多数据,如果是同步执行,通过网络请求接口可能会出现请求超时.这时候就需要使用异步执行处理了. 使用经验 代码 异步服务类 @Service // Spri ...
- Linux实战(15):Centos 防火墙常见端口命令
开启命令 firewall-cmd --zone=public --add-port=80/tcp --permanent 关闭命令 firewall-cmd --zone=public --remo ...
- mysql之慢日志查询
转自https://my.oschina.net/wuweixiang/blog/2987434 首先得配置my.cnf: #===================================== ...
- 在思科三层交换机上配置DHCP,不同网段/VLAN间互通
摘要: 描述:在三层交换机上配置DHCP,实现DHCP为PC1/PC3分配192.168.1.X网段:实现DHCP为PC2/PC4分配192.168.2.X网段:并且各个PC间要可以互相通信.(文末附 ...
- 使用maven纯注解集成ssm
1.配置springMVC框架 第一步:导入包依赖 <!--配置springMVC--> <dependency> <groupId>javax.servlet.j ...