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
相关推荐
柯南二号9 小时前
【设计模式】【观察者模式】实例
java·开发语言·servlet
Arthurmoo11 小时前
打造高效Jenkins CICD环境全解析
servlet
lucia_zl1 天前
pytest并发测试,资源问题导致用例失败解决办法
pytest
鱼鱼说测试1 天前
Selenium4+Pytest自动化测试框架实战
pytest
aristo_boyunv3 天前
拦截器和过滤器(理论+实操)
java·数据仓库·hadoop·servlet
张3蜂6 天前
CI/CD流水线驱动自动化流程深度解析:选型、竞品、成本与资源消耗
servlet·ci/cd·自动化
fqq36 天前
记录一个细节问题Servlet注解有两种方式
java·servlet·tomcat
小薛博客6 天前
26、Jenkins流水线
java·servlet·jenkins
KellenKellenHao6 天前
Jenkins调用ansible部署lnmp
servlet·ansible·jenkins
程序员的世界你不懂7 天前
【框架】基于selenium+java框架设计(0-1实战)
java·selenium·servlet