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.网络监听配置 ...
随机推荐
- SpringMVC-Controller&RestFul
Controller与RestFul 目录 Controller与RestFul 1. Controller 1. 控制器Controller 2. 利用接口定义控制器 1. 实现Controller ...
- SMBMS
SMBMS(Supermarket Billing Management System ) 目录 SMBMS(Supermarket Billing Management System ) 1. 项目 ...
- selenium常用webdriver api汇总
1.driver.current_url:用于获得当前页面的URL 2.driver.title:用于获取当前页面的标题 3.driver.page_source:用于获取页面html源代码 4.dr ...
- Golang多线程简单斗地主
多线程,通道,读写锁(单写多读),随机(洗牌),是本文涉及的主要知识点. 先看一下做出来的效果,因为是实验程序,跟真实的斗地主还是有差距,理解万岁! [发牌员]:洗牌咯. 刷刷刷... [发牌员]:牌 ...
- 学习go的一些笔记
反射 reflect type CfgSt struct{ Match *int64 `ini:"match"` Desc string `ini:"desc" ...
- ⏰ Moment.js 宣布停止开发,现在该用什么?
本文整理自 Monent.js 官方英文公告 https://momentjs.com/docs/#/-project-status/ Moment.js 宣布停止开发,进入维护状态. 这是一个大而全 ...
- Python-面向网络编程-socket原理
socket 整个计算机网络是由协议构成,想要通信必须遵守对应的协议,如Web中的http协议.传输协议TCP和UDP等等.在网络工程师的眼中,可能现在网络上的一切都是socket,一切皆socket ...
- Python练习题 044:Project Euler 016:乘方结果各个数值之和
本题来自 Project Euler 第16题:https://projecteuler.net/problem=16 ''' Project Euler 16: Power digit sum 2* ...
- GUI应用编程初体验
不同平台的GUI实现原理是一样的. 本实验基于 windos平台. 先捋一捋概念 什么是消息队列(Message Queue)假 设一个场景:系统正在处理WM_PAINT消息,就在这时用户在键盘上敲击 ...
- 深入理解Callable接口
Callable接口: Callable,新启线程的一种方式,返回结果并且可能抛出异常的任务,在前面的新启线程的文章中用过,但是没有具体讲解 优点: 可以获取线程的执行结果,也称为返回值 通过与Fut ...