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. Ubuntu Linux DNS服务器 BIND9配置文件命令介绍

    BIND9配置方法 转载▼     配置语法 named.conf acl 定义访问控制列表 controls 定义rndc命令使用的控制通道,若省略,则只允许经过rndc.key认证的127.0.0 ...

  2. Portswigger web security academy:Stored XSS

    Portswigger web security academy:Stored XSS 目录 Portswigger web security academy:Stored XSS Stored XS ...

  3. 【js】Leetcode每日一题-数组异或操作

    [js]Leetcode每日一题-数组异或操作 [题目描述] 给你两个整数,n 和 start . 数组 nums 定义为:nums[i] = start + 2*i(下标从 0 开始)且 n == ...

  4. sqlyog报错2058

    报错描述 SQLyog连接mysql8.0时,SQLyog Ultimate显示报错信息并附带乱码 "错误号码2058,Plugin caching--sha2_passward could ...

  5. 老Python带你从浅入深探究Tuple

    元组 Python中的元组容器序列(tuple)与列表容器序列(list)具有极大的相似之处,因此也常被称为不可变的列表. 但是两者之间也有很多的差距,元组侧重于数据的展示,而列表侧重于数据的存储与操 ...

  6. 【Mybatis源码解析】- 整体架构及原理

    整体架构 version-3.5.5 在深入了解Mybatis的源码之前,我们先了解一下Mybatis的整体架构和工作原理,这样有助于我们在阅读源码过程中了解思路和流程. 核心流程 在上一遍的入门程序 ...

  7. 登录框-element-ui 样式调节

    element-ui样式调节 首先设置布局 如果想要实现如下效果 需要两行,然后设置偏移,第一行中间只是站位,没有内容,可以考虑使用div占位,设置最小高度 el-card调整圆角 border-ra ...

  8. 用 set follow-fork-mode child即可。这是一个 gdb 命令,其目的是告诉 gdb 在目标应用调用fork之后接着调试子进程而不是父进程,因为在 Linux 中fork系统调用成功会返回两次,一次在父进程,一次在子进程

    GDB的那些奇淫技巧 evilpan 收录于 Security  2020-09-13  约 5433 字   预计阅读 11 分钟  709 次阅读  gdb也用了好几年了,虽然称不上骨灰级玩家,但 ...

  9. vipivp常用linux命令

    基础安装 # CentOS sudo yum install epel-release 命令行Tips 进程及端口 # 查看端口占用情况 netstat -ap | grep 端口号   # 查看某一 ...

  10. linux route命令的使用详解-(转自小C爱学习)

    route命令用于显示和操作IP路由表.要实现两个不同的子网之间的通信,需要一台连接两个网络的路由器,或者同时位于两个网络的网关来实现.在Linux系统中,设置路由通常是 为了解决以下问题:该Linu ...