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
相关推荐
大猫和小黄16 小时前
从 Servlet 到 SSM:Java Web 进化史
servlet·java web
需要8267 天前
JVM 内存区域与对象创建:一次 GC 从哪来
java·jvm·spring boot·spring·servlet·tomcat
把头塞进显示器7 天前
电商平台-测试报告
python·selenium·pytest
昔我往昔11 天前
pytest日志问题排查记录
python·pytest
黄昏恋慕黎明15 天前
博客论坛技术迭代
python·pytest
2601_9620782315 天前
Python接口自动化流程(pytest)
python·pytest·接口自动化·测试框架·断言
杨女士YRJ15 天前
python+pytest+01
python·pytest
ashiho16 天前
【Spring】RequestParam/PathVariable/RequestBody详解
java·后端·spring·servlet·springmvc
2601_9620782316 天前
Python接口自动化框架:pytest
python·pytest·接口自动化·测试框架·restfulapi
2601_9620781916 天前
Appium+Python+pytest自动化测试框架详解
自动化测试·python·appium·pytest·移动应用