安装
pip install pytest
终端运行
-
pytest:在当前目录中查找并运行所有符合测试用例命名规范的测试用例。 -
pytest -q:以简化模式运行所有测试用例。 -
pytest -v:以详细模式运行所有测试用例。 -
pytest test_sample.py:运行指定的测试文件test_sample.py中的所有测试用例。 -
pytest tests/:运行指定目录tests/下所有测试用例。 -
pytest -m "mark":运行被标记为"mark"的测试用例。 -
pytest --cov:使用覆盖率工具pytest-cov生成测试覆盖率报告。 -
pytest --cov-report=html:以HTML格式生成测试覆盖率报告。 -
pytest --fixtures:列出所有可用的fixtures(夹具)。 -
pytest --fixtures-per-test:列出在每个测试用例中使用的夹具。 - pytest --last-failed 运行上次失败用例
浙公网安备 33010602011771号