09、pytest多种调用方式

官方用例

python 复制代码
# content of myivoke.py
import sys
import pytest

class MyPlugin:
    def pytest_sessionfinish(self):
        print("*** test run reporting finishing")
        
if __name__ == "__main__":
    sys.exit(pytest.main(["-qq"],plugins=[MyPlugin()]))
python 复制代码
# content of other_invoke.py
import pytest

if __name__ == "__main__":
    retcode = pytest.main()
    print(retcode)
python 复制代码
# content of test_invok_01.py

def test_invok_01():
    print("test_invok_01 was invoked")
    assert 0

解读与实操

  • 通过pytest命令行调用
  • 通过python命令行调用
  • python代码中调用

应用场景

  • 个人调试或Jenkins调用,可使用python或pytest命令行
  • 测试平台,集成pytest时,可以在Python代码中调用pytest
相关推荐
兴趣使然黄小黄11 小时前
【Pytest】Pytest框架快速入门
python·pytest
BD_Marathon1 天前
【JavaWeb】请求转发
servlet
m0_632482501 天前
Jenkins + Pytest +allure接口自动化测试配置与操作
jenkins·集成测试·pytest·jenkins配置
李星星BruceL1 天前
Pytest第三章(参考指南1)
python·自动化·pytest
哎呀呦呵1 天前
pytest基本使用
python·pytest
Kristen_YXQDN1 天前
PyCharm 中 pytest 运行 python 测试文件报错:D:\Python_file\.venv\Scripts\python.exe: No module named pytest
运维·开发语言·python·pycharm·pytest
Low--Key1 天前
pytest框架快速入门
python·自动化·pytest
姜西西_1 天前
自动化测试框架pytest之fixture
android·java·pytest
测试开发Kevin1 天前
超级实用!汇总pytest中那些常用的参数
单元测试·pytest
Beaman10241 天前
pytest框架
python·pytest