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 小时前
心跳机制详解
java·前端·servlet
Mr_Xuhhh15 小时前
pytest -- 测试报告allure
pytest
e***282915 小时前
报错The default superclass, “jakarta.servlet.http.HttpServlet“(已经配置好tomcat)
http·servlet·tomcat
我的xiaodoujiao2 天前
使用 Python 语言 从 0 到 1 搭建完整 Web UI自动化测试学习系列 28--开源电商商城系统项目实战--封装注册页面
python·学习·测试工具·pytest
w***4242 天前
报错The default superclass, “jakarta.servlet.http.HttpServlet“(已经配置好tomcat)
http·servlet·tomcat
g***78912 天前
从0到1部署Tomcat和添加servlet(IDEA2024最新版详细教程)
hive·servlet·tomcat
Mr_Xuhhh2 天前
pytest -- fixture
开发语言·python·pytest
Mr_Xuhhh3 天前
pytest -- 指定⽤例执⾏顺序
开发语言·python·pytest
K***65893 天前
从0到1部署Tomcat和添加servlet(IDEA2024最新版详细教程)
hive·servlet·tomcat
Mr_Xuhhh3 天前
pytest -- ⽇志与测试报告
pytest