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
相关推荐
期待のcode9 小时前
图片上传实现
java·前端·javascript·数据库·servlet·交互
云和数据.ChenGuang10 小时前
运维技术教程之Jenkins的秘钥设置
运维·servlet·jenkins·自动化监控·运维技术教程
出门撞大运11 小时前
Servlet概述
servlet
云和数据.ChenGuang1 天前
运维技术教程之Jenkins上的known_hosts文件
运维·servlet·jenkins·自动化监控·运维技术教程
别在内卷了2 天前
测试学习之——Pytest Day2
服务器·学习·pytest
杨DaB2 天前
【项目实践】SMBMS(Javaweb版)汇总版
学习·spring·servlet·log4j
chao_7892 天前
pytest 实战演练【pytest】
自动化测试·单元测试·自动化·pytest
qq_513728043 天前
为什么选择 pytest 而不是 unittest
pytest
思则变3 天前
[Pytest][Part 5]单条测试和用例集测试
pytest
Bella_chene4 天前
IDEA中使用Servlet,tomcat输出中文乱码
servlet·tomcat·intellij-idea