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'])
相关推荐
我的xiaodoujiao4 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 22--数据驱动--参数化处理 Json 文件
python·学习·测试工具·pytest
胜天半月子17 小时前
Python自动化测试 | 快速认识并了解pytest的基本使用
服务器·python·pytest
北珣.5 天前
自动化框架pytest基础
自动化·pytest
程序员杰哥6 天前
Pytest之收集用例规则与运行指定用例
自动化测试·软件测试·python·测试工具·职场和发展·测试用例·pytest
学习3人组6 天前
Python + requests + pytest + allure + Jenkins 构建完整的接口自动化测试框架
python·jenkins·pytest
shao9185169 天前
Gradio全解14——使用Gradio构建MCP的服务器与客户端(4)——Python包命令:uv与uvx实战
pytest·uv·1024程序员节·npx·uvx·uv pip·ruff
我的xiaodoujiao10 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 20--PO(POM) 设计模式和用例撰写
python·学习·测试工具·设计模式·pytest
sky0Lan11 天前
一个类似 pytest 的 html 报告
android·html·pytest
一半烟火以谋生12 天前
Python + Pytest + Allure 自动化测试报告教程
开发语言·python·pytest
一半烟火以谋生13 天前
pytest conftest.py 使用教程
pytest