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
相关推荐
St_rive3 天前
Pytest skip&&skipif跳过⽤例
运维·服务器·pytest
努力搬砖的咸鱼5 天前
AI Agent测试全景图:它到底改变了什么
人工智能·python·ai·集成测试·pytest·agent·ai编程
X1A0RAN7 天前
自动化流水线提效·微观篇:pytest 执行顺序优化
自动化·pytest
lv__pf9 天前
servlet与jsp
java·开发语言·servlet
风起洛阳@不良使11 天前
Servlet体系
servlet
X1A0RAN11 天前
Jenkins Pipeline 变量打印指南
运维·servlet·jenkins
sun༒13 天前
Java Web 三大组件之 Servlet:从入门到理解生命周期
java·servlet·web
IKUN家族14 天前
Spring MVC(三)
运维·服务器·spring boot·spring·servlet·java-ee
spider_xcxc14 天前
Jenkins 遇见 Argo CD:构建可靠 GitOps 流水线的实战指南
java·开发语言·servlet