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
相关推荐
摇滚侠17 小时前
JavaWeb 全套教程 Servlet 75-81
servlet
摇滚侠20 小时前
JavaWeb 全套教程 Servlet 66-74
java·servlet·tomcat·intellij-idea·jar
我登哥MVP21 小时前
Spring Boot 从“会用”到“精通”:参数解析原理
java·spring boot·后端·spring·servlet·maven·intellij-idea
我登哥MVP1 天前
Spring Boot 从“会用”到“精通”:Model-Map原理
java·spring boot·后端·spring·servlet·maven·mybatis
弹简特1 天前
【接口自动化】01-pytest详解、pytest执行逻辑、pytest参数、配置文件和pytest标记
自动化·pytest
香辣西红柿炒蛋1 天前
pytest框架介绍
python·pytest
我登哥MVP2 天前
Spring Boot 从“会用”到“精通”:请求映射原理
java·spring boot·后端·spring·servlet·maven·intellij-idea
我登哥MVP2 天前
Spring Boot 从“会用”到“精通”:Converter 原理
java·spring boot·servlet·maven·mybatis·converter
装不满的克莱因瓶4 天前
Servlet 到 Spring MVC 架构演进:Java Web 开发二十年技术变迁史
java·spring·servlet·架构·springmvc
laufing4 天前
java web 基础 ---- servlet
java·servlet·web开发