pytest命令行参数
1.-v:可以输出用例更加详细的执行信息,如下图
C:\Users\cale\checkapi\test_cc>pytest test_m1.py -v
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0 -- c:\users\ipharmacare\python37\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.3', 'Platform': 'Windows-10-10.0.17134-SP0', 'Packages': {'pytest': '5.2.1', 'py': '1.8.0', 'pluggy': '0.13.0'}, 'Plugins': {'allure-pytest': '2.8.13', 'html': '2.0.0', 'metadata': '1.8.0', 'rerunfailures': '7.0'}}
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items test_m1.py::TestClass::test_one PASSED [ 50%]
test_m1.py::TestClass::test_two PASSED [100%] ============================================================================================================ 2 passed in 0.14s ============================================================================================================= C:\Users\cale\checkapi\test_cc>
2.-s:输出用例中的调试信息,比如print等打印信息
C:\Users\cale\checkapi\test_cc>pytest test_m1.py -s
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items test_m1.py test_one方法执行
.test_two方法执行
. ============================================================================================================ 2 passed in 0.16s =============================================================================================================
3.-m:根据标记执行特定的测试用例
C:\Users\cale\checkapi\test_cc>pytest test_m1.py -m smoke -s
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items / 1 deselected / 1 selected test_m1.py test_one方法执行
.
4.-k:执行用例中包含“关键字”的用例
C:\Users\cale\checkapi\test_cc>pytest test_m1.py -k test_one -s #test_one是用例名称,还可以是标签名或其它
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items / 1 deselected / 1 selected test_m1.py test_one方法执行
. ===================================================================================================== 1 passed, 1 deselected in 0.10s ======================================================================================================
5.-q:简化控制台的输出
C:\Users\cale\checkapi\test_cc>pytest test_m1.py -q
.. [100%]
2 passed in 0.08s
6. --collect-only:列出当前目录下所有的测试模块,测试类及测试函数
C:\Users\cale\checkapi>pytest test_cc --collect-only
========================================================================= test session starts =========================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 4 items
<Package C:\Users\cale\checkapi\test_cc>
<Module test_m1.py>
<Class TestClass>
<Function test_one>
<Function test_two>
<Module test_m2.py>
<Function test_three>
<Function test_four> ======================================================================== no tests ran in 0.24s ========================================================================
7.--tb=style(style可以是:no,line,short) 屏蔽测试用例执行输出的回溯信息,可以简化用例失败时的输出信息
C:\Users\cale\checkapi\test_cc>pytest test_m1.py --tb=line
========================================================================= test session starts =========================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items test_m1.py F. [100%] ============================================================================== FAILURES ===============================================================================
C:\Users\cale\checkapi\test_cc\test_m1.py:80: assert 1 == 2
===================================================================== 1 failed, 1 passed in 0.38s ===================================================================== C:\Users\cale\checkapi\test_cc>pytest test_m1.py --tb=no
========================================================================= test session starts =========================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items test_m1.py F. [100%] ===================================================================== 1 failed, 1 passed in 0.34s ===================================================================== C:\Users\cale\checkapi\test_cc>pytest test_m1.py --tb=short
========================================================================= test session starts =========================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0
rootdir: C:\Users\cale\checkapi\test_cc
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items test_m1.py F. [100%] ============================================================================== FAILURES ===============================================================================
_________________________________________________________________________ TestClass.test_one __________________________________________________________________________
test_m1.py:80: in test_one
assert 1==2
E assert 1 == 2
------------------------------------------------------------------------ Captured stdout call -------------------------------------------------------------------------
test_one方法执行
===================================================================== 1 failed, 1 passed in 0.33s =====================================================================
8.运行指定的测试类:pytest test_cc/m1_test.py::TestClass -v
C:\Users\cale\checkapi>pytest test_cc/m1_test.py::TestClass -v
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0 -- c:\users\ipharmacare\python37\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.3', 'Platform': 'Windows-10-10.0.17134-SP0', 'Packages': {'pytest': '5.2.1', 'py': '1.8.0', 'pluggy': '0.13.0'}, 'Plugins': {'allure-pytest': '2.8.13', 'html': '2.0.0', 'metadata': '1.8.0', 'rerunfailures': '7.0'}}
rootdir: C:\Users\cale\checkapi
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 2 items test_cc/m1_test.py::TestClass::test1 FAILED [ 50%]
test_cc/m1_test.py::TestClass::test2 PASSED
9.运行指定的测试方法:pytest test_cc/test_m2.py::test_three -v
C:\Users\cale\checkapi>pytest test_cc/test_m2.py::test_three -v
=========================================================================================================== test session starts ============================================================================================================
platform win32 -- Python 3.7.3, pytest-5.2.1, py-1.8.0, pluggy-0.13.0 -- c:\users\ipharmacare\python37\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.3', 'Platform': 'Windows-10-10.0.17134-SP0', 'Packages': {'pytest': '5.2.1', 'py': '1.8.0', 'pluggy': '0.13.0'}, 'Plugins': {'allure-pytest': '2.8.13', 'html': '2.0.0', 'metadata': '1.8.0', 'rerunfailures': '7.0'}}
rootdir: C:\Users\cale\checkapi
plugins: allure-pytest-2.8.13, html-2.0.0, metadata-1.8.0, rerunfailures-7.0
collected 1 item test_cc/test_m2.py::test_three PASSED [100%]
pytest命令行参数的更多相关文章
- Python测试框架pytest命令行参数用法
在Shell执行pytest -h可以看到pytest的命令行参数有这10大类,共132个 序号 类别 中文名 包含命令行参数数量 1 positional arguments 形参 1 2 gene ...
- pytest框架之命令行参数2
前言 上篇博客说到命令行执行测试用例的部分参数如何使用?今天将继续更新其他一些命令选项的使用,和pytest收集测试用例的规则! pytest执行用例命令行参数 --collect-only:罗列出所 ...
- pytest框架之命令行参数1
前言 pytest是一款强大的python自动化测试工具,可以胜任各种类型或者级别的软件测试工作.pytest提供了丰富的功能,包括assert重写,第三方插件,以及其他测试工具无法比拟的fixtur ...
- pytest十二:cmd命令行参数
命令行参数是根据命令行选项将不同的值传递给测试函数,比如平常在 cmd 执行”pytest —html=report.html”,这里面的”—html=report.html“就是从命令行传入的参数对 ...
- pytest封神之路第二步 132个命令行参数用法
在Shell执行pytest -h可以看到pytest的命令行参数有这10大类,共132个 序号 类别 中文名 包含命令行参数数量 1 positional arguments 形参 1 2 gene ...
- Pytest 学习(二十五)- allure 命令行参数【转】
先看看 allure 命令的帮助文档 cmd 敲 allure -h allure 命令的语法格式 allure [options] [command] [command options] optio ...
- Pytest 系列(27)- allure 命令行参数
如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 先看看 allure 命令的帮助文 ...
- Pytest(13)命令行参数--tb的使用
前言 pytest 使用命令行执行用例的时候,有些用例执行失败的时候,屏幕上会出现一大堆的报错内容,不方便快速查看是哪些用例失败. --tb=style 参数可以设置报错的时候回溯打印内容,可以设置参 ...
- python+pytest,通过自定义命令行参数,实现浏览器兼容性跑用例
场景拓展: UI自动化可能需要指定浏览器进行测试,为了做成自定义配置浏览器,可以通过动态添加pytest的命令行参数,在执行的时候,获取命令行传入的参数,在对应的浏览器执行用例. 1.自动化用例需要支 ...
随机推荐
- Win64 驱动内核编程-25.X64枚举和隐藏内核模块
X64枚举和隐藏内核模块 在 WIN64 上枚举内核模块的人方法:使用 ZwQuerySystemInformation 的第 11 号功能和枚举 KLDR_DATA_TABLE_ENTRY 中的 I ...
- 14.PHP_PHP与XML技术
PHP与XML技术 先把概念粘过来: 先来个基本模板: <?xml version="1.0" encoding="gb2312" standalone= ...
- [CTF]栅栏密码学习
[CTF]栅栏密码学习 即把将要传递的信息中的字母交替排成上下两行,再将下面一行字母排在上面一行的后边,从而形成一段密码.栅栏密码是一种置换密码. 例如密文:TEOGSDYUTAENNHLNETAMS ...
- HarmonyOS三方件开发指南(19)-BGABadgeView徽章组件
目录: 1.引言 2.功能介绍 3.BGABadgeView 使用指南 4.BGABadgeView 开发指南 5.<HarmonyOS三方件开发指南>系列文章合集 引言 现在很多的APP ...
- java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
问题描述 Tomcat启动报错 java.lang.ClassNotFoundException: org.apache.jsp.index_jsp 问题原因 因为tomcat在启动过程中jsp和se ...
- android之布局优化
android中提供了<include />.<merge />.<ViewStub />三种优化布局. 1.<include /> <inclu ...
- 使用C#实现一个PPT遥控器
说明 本项目参考了 https://github.com/yangzhongke/PhoneAsPrompter 项目来完成实现,并对其进行了一些修改完善. 完整代码可以到 https://githu ...
- Think on 小黄衫
忙忙碌碌的大三下,抽空写一篇这样的感想,感觉也是蛮不错的. 首先,还是要非常感谢课程组的认可与鼓励,能够得到这样的一件"小黄衫",确实是一段非常宝贵的体验. 博客作业感想 三次博客 ...
- 【建议收藏】缺少 Vue3 和 Spring Boot 的实战项目经验?我这儿有啊!
缺少 Vue3 和 Spring Boot 的实战项目经验?缺少学习项目和练手项目?我这儿有啊! 从 2019 年到 2021 年,空闲时间里陆陆续续做了一些开源项目,推荐给大家啊!记得点赞和收藏噢! ...
- [Qt] 事件机制(三)
在主窗口Widget中增加几个小功能 1.点击左键,在左上角label中显示"haha",点击右键,显示"lala" 在widget.h中添加: 1 #incl ...