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
相关推荐
凌冰_1 天前
IDEA2025 搭建Web并部署到Tomcat运行Servlet+Thymeleaf
java·servlet·tomcat
兴趣使然黄小黄2 天前
【Pytest】Pytest常用的第三方插件
python·pytest
凤凰战士芭比Q2 天前
Jenkins(Pipeline job)
java·servlet·jenkins
我的xiaodoujiao2 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 34--基础知识 9--文件上传功能
前端·python·测试工具·ui·pytest
我一定会有钱2 天前
pytest测试框架基础
python·单元测试·自动化·pytest
我的xiaodoujiao2 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 35--二次封装MySQL数据库连接操作
python·学习·测试工具·pytest
BD_Marathon3 天前
【JavaWeb】乱码问题_POST请求参数乱码问题
servlet
给你一页白纸3 天前
Pytest 测试用例自动生成:接口自动化进阶实践
python·pytest·接口自动化
初学者_xuan3 天前
安装与配置Jenkins(OpenEuler)
运维·servlet·jenkins
凤凰战士芭比Q3 天前
Jenkins(环境变量、构建参数、流水线触发、通知报告)
java·servlet·jenkins