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
相关推荐
Hacker_xingchen1 天前
手把手教你配置Jenkins自动化邮件通知
自动化测试·软件测试·servlet·自动化·jenkins
fīɡЙtīиɡ ℡2 天前
内存泄漏产生的原因
java·spring·servlet
我的xiaodoujiao3 天前
API 接口自动化测试详细图文教程学习系列32--Allure测试报告2
python·学习·测试工具·pytest
码上有光4 天前
异常和智能指针
java·大数据·c++·servlet·异常·智能指针
圣光SG6 天前
Servlet学习笔记
笔记·学习·servlet
一孤程6 天前
Pytest+Selenium搭建自动化框架-保姆级实战教程
selenium·自动化·pytest
智码看视界9 天前
Tomcat架构深度拆解:Connector和Container到底怎么配合的?
java·servlet·架构·tomcat·web服务器
名字还没想好☜10 天前
用 pytest fixture 组织可维护的测试:告别一堆重复的 setUp
数据库·python·oracle·pytest·测试
自动化和Linux12 天前
【pytest在pycharm中运行与CMD命令运行区别一】
python·pycharm·pytest
博观而约取厚积而薄发13 天前
Pytest 从入门到精通,一篇就够(超详细实战教程)
python·测试工具·单元测试·自动化·pytest