zoukankan      html  css  js  c++  java
  • [Pytest]运行指定的case

    运行指定的case

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

    例子代码:

    test_aa.py

    class TestClassOne(object):
        def test_one(self):
            x = "this"
            assert 't'in x
    
        def test_two(self):
            x = "hello"
            assert hasattr(x, 'check')
    
    
    class TestClassTwo(object):
        def test_one(self):
            x = "iphone"
            assert 'p'in x
    
        def test_two(self):
            x = "apple"
            assert hasattr(x, 'check')
    

      

    运行模式:

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

    pytest test_aa.py

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

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

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

    ------------------------- A little Progress a day makes you a big success... ----------------------------
  • 相关阅读:
    C#不显示在任务栏
    打开文件,文件夹
    C#文本操作
    C#路径2
    C#当前程序路径获取
    HDU 5155 Harry And Magic Box dp
    POJ 1971 Parallelogram Counting
    CodeForces 479C Exams 贪心
    CodeForces 508E Arthur and Brackets 贪心
    CodeForces 483B 二分答案
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/14846293.html
Copyright © 2011-2022 走看看