1.  -s    表示输出调试信息,包括print打印信息

D:\demo>pytest -s ./pytest_1
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item pytest_1\test_login.py 登录1
. ================================================================ 1 passed in 0.07s =================================================================

pytest -s ./pytest_1

pytest.main(['-s', './pytest_1/test_login.py'])

2.   -v   表示输出用例执行详细信息

D:\demo>pytest -v ./pytest_1
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item pytest_1/test_login.py::TestLogin::test_08_loogin1 PASSED [100%] ================================================================ 1 passed in 0.03s =================================================================

pytest -v ./pytest_1

pytest.main(['-v', './pytest_1/test_login.py'])

3.   -vs  表示既输出调试信息同时输出执行详细信息

D:\demo>pytest -vs ./pytest_1
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
PASSED ================================================================ 1 passed in 0.03s =================================================================

pytest -vs ./pytest_1

pytest.main(['-vs', './pytest_1/test_login.py'])

4.   -n   支持多线程或者分布式运行测试用例

D:\demo>pytest -vs ./pytest_1 -n 2
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
[gw0] win32 Python 3.7.4 cwd: D:\demo
[gw1] win32 Python 3.7.4 cwd: D:\demo
[gw0] Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)]
[gw1] Python 3.7.4 (tags/v3.7.4:e09359112e, Jul 8 2019, 19:29:22) [MSC v.1916 32 bit (Intel)]
gw0 [4] / gw1 [4]
scheduling tests via LoadScheduling pytest_1/test_login.py::TestLogin::test_07_login2
pytest_1/test_login.py::TestLogin::test_08_loogin1
[gw0] PASSED pytest_1/test_login.py::TestLogin::test_07_login2
pytest_1/test_login.py::TestLogin::test_09_login3
[gw1] PASSED pytest_1/test_login.py::TestLogin::test_08_loogin1
[gw0] PASSED pytest_1/test_login.py::TestLogin::test_09_login3
pytest_1/test_login.py::TestLogin::test_01_login4
[gw1] PASSED pytest_1/test_login.py::TestLogin::test_01_login4 ================================================================ 4 passed in 1.61s =================================================================

pytest -vs ./pytest_1 -n 2

pytest.main(['-vs', './pytest_1/test_login.py', '-n=2'])

5.  --reruns   失败用例重跑

D:\demo>pytest -vs ./pytest_1/test_login.py --reruns 2
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 1 item pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
RERUN
pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
RERUN
pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
FAILED ===================================================================== FAILURES =====================================================================
____________________________________________________________ TestLogin.test_08_loogin1 _____________________________________________________________ self = <pytest_1.test_login.TestLogin object at 0x04271DF0> @pytest.mark.run(order=3)
def test_08_loogin1(self):
print("登录1")
> assert 1 == 2
E assert 1 == 2
E +1
E -2 pytest_1\test_login.py:10: AssertionError
============================================================= short test summary info ==============================================================
FAILED pytest_1/test_login.py::TestLogin::test_08_loogin1 - assert 1 == 2
============================================================ 1 failed, 2 rerun in 0.11s ============================================================

pytest -vs ./pytest_1/test_login.py --reruns 2

pytest.main(['-vs', './pytest_1/test_login.py', '--reruns=2'])

6.   -x   只要存在失败用例则停止执行

D:\demo>pytest -vs ./pytest_1/test_login.py -x
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 4 items pytest_1/test_login.py::TestLogin::test_07_login2 登录2
PASSED
pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
FAILED ===================================================================== FAILURES =====================================================================
____________________________________________________________ TestLogin.test_08_loogin1 _____________________________________________________________ self = <pytest_1.test_login.TestLogin object at 0x0423D3D0> @pytest.mark.run(order=3)
def test_08_loogin1(self):
print("登录1")
> assert 1 == 2
E assert 1 == 2
E +1
E -2 pytest_1\test_login.py:10: AssertionError
============================================================= short test summary info ==============================================================
FAILED pytest_1/test_login.py::TestLogin::test_08_loogin1 - assert 1 == 2
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=========================================================== 1 failed, 1 passed in 0.11s ============================================================

pytest -vs ./pytest_1/test_login.py -x

pytest.main(['-vs', './pytest_1/test_login.py', '-x'])

7.   --maxfail   只要存在max个失败用例则停止执行

D:\demo>pytest -vs ./pytest_1/test_login.py --maxfail 2
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 4 items pytest_1/test_login.py::TestLogin::test_07_login2 登录2
PASSED
pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
FAILED
pytest_1/test_login.py::TestLogin::test_09_login3 登录3
PASSED
pytest_1/test_login.py::TestLogin::test_01_login4 登录4
PASSED ===================================================================== FAILURES =====================================================================
____________________________________________________________ TestLogin.test_08_loogin1 _____________________________________________________________ self = <pytest_1.test_login.TestLogin object at 0x04CAEFB0> @pytest.mark.run(order=3)
def test_08_loogin1(self):
print("登录1")
> assert 1 == 2
E assert 1 == 2
E +1
E -2 pytest_1\test_login.py:10: AssertionError
============================================================= short test summary info ==============================================================
FAILED pytest_1/test_login.py::TestLogin::test_08_loogin1 - assert 1 == 2
=========================================================== 1 failed, 3 passed in 0.08s ============================================================

pytest -vs ./pytest_1/test_login.py --maxfail 2

pytest.main(['-vs', './pytest_1/test_login.py', '--maxfail=2'])

8.  -k   根据测试用例的部分字符串执行用例

D:\demo>pytest -vs ./pytest_1/test_login.py -k "oo"
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 4 items / 3 deselected / 1 selected pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
FAILED ===================================================================== FAILURES =====================================================================
____________________________________________________________ TestLogin.test_08_loogin1 _____________________________________________________________ self = <pytest_1.test_login.TestLogin object at 0x045420B0> @pytest.mark.run(order=3)
def test_08_loogin1(self):
print("登录1")
> assert 1 == 2
E assert 1 == 2
E +1
E -2 pytest_1\test_login.py:10: AssertionError
============================================================= short test summary info ==============================================================
FAILED pytest_1/test_login.py::TestLogin::test_08_loogin1 - assert 1 == 2
========================================================= 1 failed, 3 deselected in 0.07s ==========================================================

pytest -vs ./pytest_1/test_login.py -k "oo"

pytest.main(['-vs', './pytest_1/test_login.py', '-k=oo'])

9. --html 生成测试报告

D:\demo>pytest --html ./reports/report.html
=============================================================== test session starts ================================================================
platform win32 -- Python 3.7.4, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 -- d:\program files\python\python37-32\python.exe
cachedir: .pytest_cache
metadata: {'Python': '3.7.4', 'Platform': 'Windows-10-10.0.17763-SP0', 'Packages': {'pytest': '6.2.4', 'py': '1.10.0', 'pluggy': '0.13.1'}, 'Plugins'
: {'allure-pytest': '2.9.43', 'forked': '1.3.0', 'html': '3.1.1', 'metadata': '1.11.0', 'ordering': '0.6', 'rerunfailures': '10.0', 'xdist': '2.3.0'}
, 'JAVA_HOME': 'D:\\Program Files\\Java\\jdk1.8.0_221'}
rootdir: D:\demo, configfile: pytest.ini, testpaths: ./pytest_1
plugins: allure-pytest-2.9.43, forked-1.3.0, html-3.1.1, metadata-1.11.0, ordering-0.6, rerunfailures-10.0, xdist-2.3.0
collected 4 items pytest_1/test_login.py::TestLogin::test_07_login2 登录2
PASSED
pytest_1/test_login.py::TestLogin::test_08_loogin1 登录1
PASSED
pytest_1/test_login.py::TestLogin::test_09_login3 SKIPPED (大于18跳过)
pytest_1/test_login.py::TestLogin::test_01_login4 登录4
PASSED ================================================================= warnings summary =================================================================
pytest_1\test_login.py:22
D:\demo\pytest_1\test_login.py:22: PytestUnknownMarkWarning: Unknown pytest.mark.usermanager - is this a typo? You can register custom marks to av
oid this warning - for details, see https://docs.pytest.org/en/stable/mark.html
@pytest.mark.usermanager -- Docs: https://docs.pytest.org/en/stable/warnings.html
--------------------------------------------- generated html file: file://D:\demo\reports\report.html ----------------------------------------------
===================================================== 3 passed, 1 skipped, 1 warning in 0.05s ======================================================

pytest --html ./reports/report.html

pytest常用参数汇总的更多相关文章

  1. hive set 常用参数汇总

    1. set hive.auto.convert.join = true; mapJoin的主要意思就是,当链接的两个表是一个比较小的表和一个特别大的表的时候,我们把比较小的table直接放到内存中去 ...

  2. Django框架ORM常用参数汇总_模型层

    primary_key 如果为True,那么这个字段就是模型的主键. 如果你没有指定任何一个字段的primary_key=True, Django就会自动添加一个IntegerField字段做为主键, ...

  3. 20145222《信息安全系统设计基础》Linux常用命令汇总

    学习Linux时常用命令汇总 通过Ctrl+f键可在该网页搜索到你想要的命令. Linux中命令格式为:command [options] [arguments] //中括号代表是可选的,即有些命令不 ...

  4. Oozie命令行常用命令汇总[转]

    Oozie命令行常用命令汇总 有时候脚本跑多了就不愿意在OozieWeb端去看脚本的运行情况了.还好Oozie提供了很多命令行命令.能通过命令行直接检索自己想看到的脚本信息.在这里简单进行一下总结.一 ...

  5. JavaScript之Array常用函数汇总

    [20141121]JavaScript之Array常用功能汇总 *:first-child { margin-top: 0 !important; } body>*:last-child { ...

  6. JVM参数汇总

    一.java启动参数共分为三类: 其一是标准参数(-),所有的JVM实现都必须实现这些参数的功能,而且向后兼容:其二是非标准参数(-X),默认jvm实现这些参数的功能,但是并不保证所有jvm实现都满足 ...

  7. 【PHP】最详细PHP从入门到精通(三)——PHP中的数组常用函数汇总

     PHP从入门到精通 之PHP中的数组常用函数详解 数组作为PHP中最常用的结构之一,PHP强大的数组函数功能,给数组的相关操作带来了极大的便利.今天给大家介绍的PHP中数组函数,是PHP数组中重要的 ...

  8. AngularJS进阶(十二)AngularJS常用知识汇总(不断更新中....)

    AngularJS常用知识汇总(不断更新中....) 注:请点击此处进行充电! app.controller('editCtrl',['$http','$location','$rootScope', ...

  9. hadoop记录-Hadoop参数汇总

    Hadoop参数汇总 linux参数 以下参数最好优化一下: 文件描述符ulimit -n 用户最大进程 nproc (hbase需要 hbse book) 关闭swap分区 设置合理的预读取缓冲区 ...

  10. Linux系统IO分析工具之iotop常用参数介绍

      Linux系统IO分析工具之iotop常用参数介绍 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 在一般运维工作中经常会遇到这么一个场景,服务器的IO负载很高(iostat中的 ...

随机推荐

  1. 持续集成指南:GitLab 的 CI/CD 工具配置与使用

    前言 写代码这项工作,本质就是将工作自动化,减少手工操作提供效率,因为人的本质都是懒狗,程序员也不能例外,为了各种意义的效率提升(懒),我们需要持续集成工具,将代码测试.编译.发布这些重复性很高的工作 ...

  2. SpringBoot入门项目CRM学习过程中的报错记录(更新ing)

    在用mybatis自动生成实体类和mapper时报错..... is unrecognized or represents more than one time zone. You must conf ...

  3. 齐博x1换服务器如何转移网站?

    如果你要把网站从本机传到服务器,又或者要更换服务器,请按下面的操作处理 第一步,必须要在原网站后台备份数据. 第二步,把备份好的网站所有文件,传到新服务器或空间 特别要注意 \cache\ 目录下建议 ...

  4. VSCode设置鼠标滚轮滑动设置字体大小

    1. 打开"文件->首选项->设置 2. 打开settings.json文件 3. 在setting.json 中添加"editor.mouseWheelZoom&qu ...

  5. SQL Server-表结构的操作

    1.修改表的字段的数据类型 alter table [File_Info] alter column Upload_Request_ID nvarchar(14) not null 2.添加表的字段并 ...

  6. 十三、Pod的资源控制器类型

    Pod 的资源控制器类型 一.Pod 的资源控制器类型 什么是控制器呢?简单来说,控制器就好比是影视剧里面的剧本,演员会根据剧本所写的内容来针对不同的角色进行演绎,而我们的控制器就好比是剧本,Kube ...

  7. c语言求输入的任一整数的各位数之和

    c语言求解代码: # include<stdio.h> int main(void){ int a,i=0,sum=0; scanf("%d",&a); if( ...

  8. 一键部署haproxy脚本

    HAPROXY_VERSION=2.6.6 HAPROXY_FILE=haproxy-${HAPROXY_VERSION}.tar.gz #HAPROXY_FILE=haproxy-2.2.12.ta ...

  9. windows中 mysql 免安装版安装

    基本安装 绝对路径中避免出现中文,推荐首选英文为命名条件! 以管理员身份打开命令行,并转到mysql的bin目录下 安装mysql服务 mysqld --install 若出现以下错误,需将缺失的文件 ...

  10. python 类相关 下划线相关 __init__

    类 1.静态方法 class C(object): @staticmethod def f(): print('runoob'); C.f(); # 静态方法无需实例化 cobj = C() cobj ...