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'])
相关推荐
兴趣使然黄小黄2 天前
【Pytest】使用Allure生成企业级测试报告
python·pytest
少云清3 天前
【接口测试】4_代码实现 _pytest框架
pytest·接口测试
屋顶那猫3 天前
使用pyinstaller打包pytest项目
python·pytest
zyx没烦恼4 天前
pytest框架
pytest
兴趣使然黄小黄6 天前
【Pytest】Pytest常用的第三方插件
python·pytest
我的xiaodoujiao6 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 34--基础知识 9--文件上传功能
前端·python·测试工具·ui·pytest
我一定会有钱6 天前
pytest测试框架基础
python·单元测试·自动化·pytest
我的xiaodoujiao6 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 35--二次封装MySQL数据库连接操作
python·学习·测试工具·pytest
给你一页白纸7 天前
Pytest 测试用例自动生成:接口自动化进阶实践
python·pytest·接口自动化
工会主席-阿冰7 天前
使用pytest-selenium插件,ui自动化示例
selenium·pytest