Pytest 总结

Pytest 总结

在这个pytest教程中,我们涵盖了以下几个方面:

  • 安装pytest
  • 识别测试文件和测试函数。
  • 使用pytest -v执行所有测试文件。
  • 使用pytest <filename> -v执行特定文件。
  • 通过子串匹配执行测试 pytest -k <子串> -v.
  • 基于标记执行测试 pytest -m -v.
  • 使用@pytest.fixture创建夹具。
  • conftest.py允许从多个文件访问固定装置。
  • 使用@pytest.mark.parametrize对测试进行参数化。
  • 使用@pytest.mark.xfail.Xfail测试失败。
  • 使用@pytest.mark.skip跳过测试。
  • 使用pytest --maxfail = <num>在n次失败时停止测试执行。
  • 使用pytest -n <num>并行运行测试。
  • 使用pytest -v –junitxml = “result.xml “生成结果xml。

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程