pytest框架
-
命名
文件*test或test*
类Test*
方法test_* -
运行
指定模块,目录 file/dir
指定模块、类、方法 file::class::method
指定标记 -m
失败停止 -x,–maxfail=num
关键字 -k
收集不运行 -co
生成junit报告 --junit-xml
显示fixture调用 --setupshow -
setup和teardown
-
fixture
scope:session, module, class, function
params:参数,列表,request fixture接收
autouse
ids -
参数化
pytest.mark.parametrize(‘a, b, c’, yaml.safe_load(open(’…’))) -
mark
-
skip, skipif
-
插件
pytest-rerunfailures
pytest-xdict
pytest-assume
pytest-ordering -
conftest
-
预期失败xfail
-
fixture调用方式
函数或方法中直接传入fixture函数名
@pytest.mark.usefixture()
autouse=True
allure