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
相关推荐
超级无敌永恒暴龙战士14 小时前
SpringMVC-执行流程
spring·servlet·springmvc
麓殇⊙17 小时前
Servlet--快速入门及HTTP概述
网络协议·http·servlet
测试开发Kevin2 天前
以pytest_addoption 为例,讲解pytest框架中钩子函数的应用
python·pytest
默心3 天前
jenkins配置多nexus仓库多maven版本
servlet·jenkins·maven
飞鸟吟4 天前
【C++】类和对象(一)
c++·servlet
magic 2456 天前
深入理解 Spring MVC:DispatcherServlet 与视图解析机制
java·servlet·状态模式·springmvc
小Tomkk6 天前
jenkins 远程执行 定时 执行shell
运维·servlet·jenkins
Microsoft Word7 天前
Servlet
hive·hadoop·servlet
川石教育7 天前
Pytest中的fixture装饰器详解
python自动化测试·pytest·pytest自动化测试框架·pytest测试框架·pytest单元测试框架
春风又。7 天前
接口自动化——参数化
python·测试工具·自动化·pytest