pytest入门五:命令行参数

-v:一般在调试的时候加上这个参数,端会打印出每条用例的详细日志信息,方便定位问题

-s:当你的代码里面有print输出语句,如果想在运行结果中打印print输出的代码(默认控制台是不输出打印结果的),在运行的时候可以添加 -s 参数,一般在调试的时候使用

-k:只执行含有某个关键字的测试用例

复制代码
pytest -k "类名"
pytest -k "方法名"
pytest -k "类名 and not 方法名"

-m:将运行有 @pytest.mark.[标记名] 这个标记的测试用例

-x:遇到用例失败立即停止运行

--maxfail:用例失败个数达到阈值停止运行

复制代码
pytest --maxfail x

pytest -v -s test.py

pytest -v -s -x test.py 或者

pytest -v -s --maxfail 1 test.py

pytest -v -s -m add test.py

复制代码
if __name__ == "__main__":
    pytest.main(['-v', '-s','-m add','test.py'])

pytest -v -s -k "test_mark" test.py

相关推荐
兴趣使然黄小黄1 天前
【Pytest】Pytest框架快速入门
python·pytest
m0_632482502 天前
Jenkins + Pytest +allure接口自动化测试配置与操作
jenkins·集成测试·pytest·jenkins配置
李星星BruceL2 天前
Pytest第三章(参考指南1)
python·自动化·pytest
哎呀呦呵2 天前
pytest基本使用
python·pytest
Kristen_YXQDN2 天前
PyCharm 中 pytest 运行 python 测试文件报错:D:\Python_file\.venv\Scripts\python.exe: No module named pytest
运维·开发语言·python·pycharm·pytest
Low--Key2 天前
pytest框架快速入门
python·自动化·pytest
姜西西_2 天前
自动化测试框架pytest之fixture
android·java·pytest
测试开发Kevin2 天前
超级实用!汇总pytest中那些常用的参数
单元测试·pytest
Beaman10242 天前
pytest框架
python·pytest
昔时扬尘处3 天前
【Files Content Replace】文件夹文件内容批量替换自动化测试脚本
c语言·python·pytest·adi