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
相关推荐
昔时扬尘处12 小时前
【Files Content Replace】文件夹文件内容批量替换自动化测试脚本
c语言·python·pytest·adi
我的xiaodoujiao17 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 32--开源电商商城系统项目实战--如何区分登录状态
python·学习·测试工具·pytest
昔时扬尘处19 小时前
如何检测python和pytest的安装环境
开发语言·python·pytest·自动化测试平台·adi
BD_Marathon21 小时前
【JavaWeb】HttpServletRequest_获取请求行和请求头
servlet
我的xiaodoujiao21 小时前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 33--基础知识 8--切换窗口句柄
python·学习·测试工具·pytest
BD_Marathon1 天前
【JavaWeb】Servlet_url-pattern的一些特殊写法问题
java·开发语言·servlet
BD_Marathon1 天前
【JavaWeb】Servlet_jar包导入和Content-Type问题
java·servlet·jar
梦想的旅途22 天前
媒体文件(图片/文件)的上传与管理:获取 Media ID 的技术细节
前端·http·servlet
要站在顶端2 天前
Jenkins PR编号提取&环境变量赋值问题总结
java·servlet·jenkins
BD_Marathon2 天前
【JavaWeb】ServletConfig为Servlet提供配置参数
servlet