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. Listview滑动时不加载数据,停下来时加载数据,让App更优

    http://blog.csdn.net/yy1300326388/article/details/45153813

  2. XCTF-mfw

    mfw mfw是什么东西??? 看题: 进来只有几个标签,挨着点一遍,到About页面 看到了Git,猜测有git泄露,访问/.git/HEAD成功 上Githack,但是会一直重复 按了一次ctrl ...

  3. Jedis基础详解

    Jedis 使用Java来操作Redis 什么是Jedis 是Redis官方推荐的Java操作Redis中间件, 如果你要使用Java操作Redis, 那么就该对jedis熟悉 测试 导入对应的依赖 ...

  4. ES6新增常用方法

    字符串新增方法 padStart.padEnd 如果原字符串不够指定长度,则会在左侧(右侧)填充字符串,用以补全 padStart( length: number, fillStr?: string ...

  5. Codeforces Round #660 (Div. 2)

    A. Captain Flint and Crew Recruitment 题意:定义了一种数(接近质数),这种数可以写成p*q并且p和q都是素数,问n是否可以写成四个不同的数的和,并且保证至少三个数 ...

  6. [Python] tkinter 之 Listbox & Combobox

    示例: 1 #用户界面 2 import os 3 os.chdir('F:\\spyder_workspace\\ColCal') 4 import Main 5 from tkinter impo ...

  7. python实现UDP通讯

    Environment Client:Windows Server:KaLi Linux(VM_virtul) Network:Same LAN Client UDPClient.py #-*- co ...

  8. ubuntu中安装qgit工具-(转自Linux中国)

    QGit是一款由Marco Costalba用Qt和C++写的开源的图形界面 Git 客户端.它是一款可以在图形界面环境下更好地提供浏览版本历史.查看提交记录和文件补丁的客户端.它利用git命令行来执 ...

  9. MyBatis 动态 SQL 语句中出现 '<' 的问题

    问题描述 映射接口方法如下: /** * 根据姓名和年龄查询用户信息 * @param name 姓名 * @param user 获取年龄 * @return */ public List<U ...

  10. session.flush()与session.clear()区别与使用环境

    session是有一级缓存的,目的是为了减少查询数据库的时间,提高效率,生命周期与session是一样的 session.flush() 是将session的缓存中的数据与数据库同步 事物提交失败 缓 ...