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
相关推荐
瑞码空间11 小时前
JSP与Servlet核心开发与CRUD实战笔记
java·笔记·servlet·jsp
追星星の人2 天前
java web项目(eclipse软件)全流程备份
java·servlet
2601_967987375 天前
Python在自动化测试中有哪些应用?
python自动化测试·selenium·appium·pytest·性能测试
小刘在重生~6 天前
Servlet_day2 (上)|Servlet 整合 JDBC|请求转发 forward|Request 作用域
hive·hadoop·servlet
Madison-No710 天前
pytest框架
pytest
鬼手点金11 天前
单轮对话:最简单的 API 调用
java·服务器·前端·javascript·react.js·servlet·tomcat
步行cgn12 天前
Servlet 中的三个域对象
servlet
骇客野人12 天前
CI/CD A 服务器(构建机)免密登录 B 服务器(目标部署机)完整操作
服务器·servlet·ci/cd
凛铄linshuo15 天前
分析业务流程什么时候适合断言?
python·pytest
凛铄linshuo16 天前
自动化测试:pytest第一个实例学习
学习·pytest