首页 > 其他 > 详细

[Pytest]运行指定的case

时间:2020-01-03 18:13:32      阅读:257      评论:0      收藏:0      [点我收藏+]

运行指定的case

  当我们写了较多的cases时,如果每次都要全部运行一遍,无疑是很浪费时间的,通过指定case来运行就很方便了。

例子代码:

class TestClassOne(object):
    def test_one(self):
        x = "this"
        assert tin x

    def test_two(self):
        x = "hello"
        assert hasattr(x, check)


class TestClassTwo(object):
    def test_one(self):
        x = "iphone"
        assert pin x

    def test_two(self):
        x = "apple"
        assert hasattr(x, check)

 

运行模式:

模式1:直接运行test_se.py文件中的所有cases:

pytest test_se.py

模式2:运行test_se.py文件中的TestClassOne这个class下的两个cases:

pytest test_se.py::TestClassOne

模式3:运行test_se.py文件中的TestClassTwo这个class下的test_one:

pytest test_se.py::TestClassTwo::test_one


注意:定义class时,需要以T开头,不然pytest是不会去运行该class的。



作者:呆呆冬
链接:https://www.jianshu.com/p/932a4d9f78f8
来源:简书
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。

 

参考文档:

全功能Python测试框架:pytest

[Pytest]运行指定的case

原文:https://www.cnblogs.com/kaerxifa/p/12145527.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!