pytest + yaml 框架 -8.一个yaml 文件可以支持多个用例了

前言

一个yaml 文件中可以写多个用例,yaml 文件相当于py模块,每个用例相当于模块里面定义 pytest 的一个函数,
用例名称最好是test开头,如果不是test开头,也会帮你自动拼接成test开头的

pip 安装插件

pip install pytest-yaml-yoyo

yaml 文件写多个用例功能在 v1.0.6 版本上实现

基本用例执行

在pytest 用例中,我们可以在一个模块写多个函数式的用例,每个用例test开头,如下

import pytest


def test1():
    """用例1"""
    print("hello 111")


def test2():
    """用例2"""
    print("hello 222")


def test3():
    """用例3"""
    print("hello 333")


if __name__ == '__main__':
    pytest.main(['-s', 'test_sample.py'])

执行后会看到3个用例

collected 3 items

test_sample.py hello 111
.hello 222
.hello 333
.

=============== 3 passed in 0.01s ===&
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值