目录:
1.参数化
2.断言
3.从json文件导入测试数据
4.运行pytest的3种方法
5.生成测试报告
6.Fixture(前置和后置)
---------------------------------------------------------------------------------------------------------------------------------
1.参数化
import pytest
from common.read_data import build_data
from tools import add
class TestAdd:
@pytest.mark.parametrize('a, b, expect', build_data()) # 参数化
def test_add_1(self, a, b, expect):
assert expect == add(a, b)
---------------------------------------------------------------------------------------------------------------------------------
2.断言
import pytest
from common.read_data import build_data
from tools import add
class TestAdd:
@pytest.mark.parametr