pytest测试框架基础知识

pytest框架

  1. 命名
    文件*test或test*
    类Test*
    方法test_*

  2. 运行
    指定模块,目录 file/dir
    指定模块、类、方法 file::class::method
    指定标记 -m
    失败停止 -x,–maxfail=num
    关键字 -k
    收集不运行 -co
    生成junit报告 --junit-xml
    显示fixture调用 --setupshow

  3. setup和teardown

  4. fixture
    scope:session, module, class, function
    params:参数,列表,request fixture接收
    autouse
    ids

  5. 参数化
    pytest.mark.parametrize(‘a, b, c’, yaml.safe_load(open(’…’)))

  6. mark

  7. skip, skipif

  8. 插件
    pytest-rerunfailures
    pytest-xdict
    pytest-assume
    pytest-ordering

  9. conftest

  10. 预期失败xfail

  11. fixture调用方式
    函数或方法中直接传入fixture函数名
    @pytest.mark.usefixture()
    autouse=True

allure

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值