前言
一个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 ===&