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
相关推荐
金玉满堂@bj14 小时前
Pytest 完整使用教程
运维·服务器·pytest
解决问题no解决代码问题15 小时前
Quartz 1.6.5
数据库·servlet·oracle
测试员周周20 小时前
【Appium 系列】第10节-手势操作实战 — 滑动、拖拽、缩放与轻拂
linux·服务器·开发语言·人工智能·python·appium·pytest
金玉满堂@bj20 小时前
pytest+uiautomation+allure 数据驱动桌面自动化项目搭建指南-yaml版本
运维·自动化·pytest
金玉满堂@bj20 小时前
pytest+uiautomation+allure+Excel 数据驱动桌面自动化
自动化·excel·pytest
Linux运维技术栈21 小时前
Jenkins服务器更新密钥后任务构建不了?排查实录与解决方案
服务器·servlet·jenkins
Be reborn2 天前
用例不是孤立执行的:依赖、变量池与 storage_state 设计
python·自动化·pytest
小陈的进阶之路2 天前
安集商城接口自动化项目架构介绍
python·自动化·pytest
测试员周周2 天前
【Appium 系列】第08节-pytest 集成 — conftest.py 中的 fixture 与 hook
开发语言·人工智能·python·功能测试·appium·测试用例·pytest
Be reborn2 天前
从一行 CSV 到一次浏览器操作:关键字驱动执行引擎设计
python·自动化·pytest