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命令行参数的更多相关文章

  1. Python测试框架pytest命令行参数用法

    在Shell执行pytest -h可以看到pytest的命令行参数有这10大类,共132个 序号 类别 中文名 包含命令行参数数量 1 positional arguments 形参 1 2 gene ...

  2. pytest框架之命令行参数2

    前言 上篇博客说到命令行执行测试用例的部分参数如何使用?今天将继续更新其他一些命令选项的使用,和pytest收集测试用例的规则! pytest执行用例命令行参数 --collect-only:罗列出所 ...

  3. pytest框架之命令行参数1

    前言 pytest是一款强大的python自动化测试工具,可以胜任各种类型或者级别的软件测试工作.pytest提供了丰富的功能,包括assert重写,第三方插件,以及其他测试工具无法比拟的fixtur ...

  4. pytest十二:cmd命令行参数

    命令行参数是根据命令行选项将不同的值传递给测试函数,比如平常在 cmd 执行”pytest —html=report.html”,这里面的”—html=report.html“就是从命令行传入的参数对 ...

  5. pytest封神之路第二步 132个命令行参数用法

    在Shell执行pytest -h可以看到pytest的命令行参数有这10大类,共132个 序号 类别 中文名 包含命令行参数数量 1 positional arguments 形参 1 2 gene ...

  6. Pytest 学习(二十五)- allure 命令行参数【转】

    先看看 allure 命令的帮助文档 cmd 敲 allure -h allure 命令的语法格式 allure [options] [command] [command options] optio ...

  7. Pytest 系列(27)- allure 命令行参数

    如果你还想从头学起Pytest,可以看看这个系列的文章哦! https://www.cnblogs.com/poloyy/category/1690628.html 先看看 allure 命令的帮助文 ...

  8. Pytest(13)命令行参数--tb的使用

    前言 pytest 使用命令行执行用例的时候,有些用例执行失败的时候,屏幕上会出现一大堆的报错内容,不方便快速查看是哪些用例失败. --tb=style 参数可以设置报错的时候回溯打印内容,可以设置参 ...

  9. python+pytest,通过自定义命令行参数,实现浏览器兼容性跑用例

    场景拓展: UI自动化可能需要指定浏览器进行测试,为了做成自定义配置浏览器,可以通过动态添加pytest的命令行参数,在执行的时候,获取命令行传入的参数,在对应的浏览器执行用例. 1.自动化用例需要支 ...

随机推荐

  1. Day003 位运算

    位运算 & 按位与,全1才为1,否则为0 | 按位或,全0才为0,否则为1 ^ 按位异或,相同则为0,不通则为1 ~按位取反 <<左移,相当于*2 >>右移,相当于/2 ...

  2. Mac使用brew搭建LNMP

    一. brew常用命令 安装brew /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/in ...

  3. 阿里云短信服务 PHP

    1.开通短信服务后,进入控制器->短信服务 2.点击国内消息,配置签名,模板(这里不作详细介绍) 3.点击进入左侧帮助文档里面,找到PHP sdk,Composer命令直接安装 4.获取acce ...

  4. locustfile中的User类和HttpUser类

    locustfile是什么? locustfile是Locust性能测试工具的用户脚本,描述了单个用户的行为. locustfile是个普通的Python模块,如果写作locustfile.py,那么 ...

  5. Redis内存——内存消耗(内存都去哪了?)

    最新:Redis内存--三个重要的缓冲区 最新:Redis内存--内存消耗(内存都去哪了?) 最新:Redis持久化--如何选择合适的持久化方式 最新:Redis持久化--AOF日志 更多文章... ...

  6. UVA OJ 623 500!

    500!  In these days you can more and more often happen to see programs which perform some useful cal ...

  7. MyBaits自动配置原理

    前言 首先我们建立一个SpringBoot工程,导入mybatis-spring-boot-starter依赖. <dependency> <groupId>org.mybat ...

  8. LVS跨网段DR模型

    客户端IP地址:172.16.8.147 路由器服务器IP地址:172.16.8.167内网IP地址:192.168.1.3 一.将客户端的网关修改为路由服务器IP地址 vim ifcfg-ens33 ...

  9. 基于混合云模式的calico部署

    开始前准备 确定calico数据存储 Calico同时支持kubernetes api和etcd数据存储.官方给出的建议是在本地部署中使用K8S API,仅支持Kubernetes模式.而官方给出的e ...

  10. WPS 2010 页眉下方添加下划线

    我们在使用Word2010编辑文档中时,有时需要在页眉下方删除或添加一条横线.本篇经验就来介绍一下删除和添加横线的方法. 工具/原料   Word 2010 一.删除横线   1 打开Word2010 ...