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
相关推荐
未定义.2219 小时前
第1篇:0基础入门!Python+Selenium环境搭建与第一个自动化脚本
python·功能测试·selenium·自动化·jenkins·pytest
编程大师哥10 小时前
如何使用Servlet进行请求转发和重定向?
servlet
凌冰_11 小时前
Thymeleaf 一个Servlet处理多个请求(六)
servlet
Lucifer__hell12 小时前
【Pytest】笔记
笔记·pytest·测试
旦莫12 小时前
使用OCR加持的APP自动化测试
python·测试开发·自动化·ocr·pytest·ai测试
工会主席-阿冰15 小时前
在pytest-html页面,显示测试用例日志
pytest
AIGCExplore1 天前
Jenkins 全局配置及工具验证教程
java·servlet·jenkins
小王不爱笑1321 天前
Java架构从单体到微服务历程
servlet
小二·1 天前
Python Web 开发进阶实战:全链路测试体系 —— Pytest + Playwright + Vitest 构建高可靠交付流水线
前端·python·pytest