pytest --collectonly 收集测试案例

pytest --collectonly 是一条命令行指令,用于在运行 pytest 测试时仅收集测试项而不执行它们。它会显示出所有可用的测试项列表,包括测试模块、测试类和测试函数,但不会执行任何实际的测试代码。

这个命令对于查看项目中的测试结构和确保所有的测试项都能被正确识别非常有用。通过检查收集到的测试项,你可以确保你的测试代码被正确组织,并且所有的测试都被识别出来。

请注意,pytest --collectonly 命令不会运行任何测试代码,它只是用来收集测试项的元数据信息。如果你想要执行实际的测试,可以使用 pytest 命令,或者添加其他选项和标志来指定运行的测试范围。

复制代码
import pytest

if __name__ == '__main__':
    # pytest.main(['-v', '--emoji', './case', '--html=./report/report.html', '--self-contained-html'])
    pytest.main(['-s',  '--collectonly', './case'])
相关推荐
Yorlen_Zhang4 小时前
Python pytest assert 断言
python·servlet·pytest
纯纯沙口2 天前
pytest - 基础使用教程
pytest
问道飞鱼2 天前
【自动化测试】pytest 语法与核心概念
自动化测试·pytest·playwright
zUlKyyRC2 天前
基于一阶RC模型,FFRLS+EKF算法的电池SOC在线联合估计Matlab程序
pytest
我的xiaodoujiao4 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 40--完善优化 Allure 测试报告显示内容
python·学习·测试工具·pytest
我的xiaodoujiao4 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 41--自定义定制化展示 Allure 测试报告内容
python·学习·测试工具·pytest
nvd114 天前
Pytest 异步数据库测试实战:基于 AsyncMock 的无副作用打桩方案
数据库·pytest
nvd115 天前
深入分析:Pytest异步测试中的数据库会话事件循环问题
数据库·pytest
程序员雷叔5 天前
在postman设置请求里带动态token,看看这两种方法!
selenium·测试工具·单元测试·测试用例·pytest·lua·postman