unittest之跳过用例(skip) (含如何调用类里面函数相互调取变量的方法)

 

当测试用例写完后,有些模块有改动时候,会影响到部分用例的执行,这个时候我们希望暂时跳过这些用例。

或者前面某个功能运行失败了,后面的几个用例是依赖于这个功能的用例,如果第一步就失败了,后面的用例也就没必要去执行了,直接跳过就行,节省用例执行时间。

 

一、skip装饰器

skip装饰器一共有四个

   @unittest.skip(reason)

  • Unconditionally skip the decorated test. reason should describe why the test is being skipped.

    翻译:无条件跳过用例,reason是说明原因

  • @unittest.skipIf(conditionreason)

  • Skip the decorated test if condition is true.

    翻译:condition为true的时候跳过

  • @unittest.skipUnless(conditionreason)

  • Skip the decorated test unless condition is true.

    翻译:condition为False的时候跳过

  • @unittest.expectedFailure

  • Mark the test as an expected failure. If the test fails when run, the test is not counted as a failure.

    翻译:断言的时候跳过(暂时不知道有啥用,没看懂,貌似断言失败,也变成用例pass了。)

  •  

 

 

 

后记:

这里有个问题,不 知道怎么解决:

 

最后解决方法:

 

发现也是错了上面那个方法

待解决

 最后解决方法,有2个思路,

一个是 把函数的变量放到一个数组里面 ,下个函数区调用这个数组

一个是存到外部的excel or txt 什么的,然后下个函数去表里取对应数据回来

 

转载于:https://www.cnblogs.com/kaibindirver/p/9406390.html

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值