zoukankan      html  css  js  c++  java
  • pytest 插件之pytest-ordering

    pytest本身执行测试用例是无序的,若要按照一定的顺序,可以按照下面的方式进行:

    先要安装该插件,pip3 install pytest-ordering,然后加上如下装饰器,既可以运行

    1、标记于被测试函数, @pytest.mark.run(order=x)
    2、根据order传入的参数来解决运行顺序
    3、order值全为正数或负数时,值越小优先级越高
    4、正负数同时存在时,正数优先极高
    5、已标记和未标记的函数,已标记的函数优先极高

    class TestBBB:
    
        @pytest.mark.run(order=10)
        def test_demo1(self):
            assert 2 == 2
            assert 2 == 2
            assert 2 == 2
            assert 2 == 2
    
        @pytest.mark.run(order=1)
        def test_demo2(self):
            assert 23 == 23
            assert 23 == 23
    

      

    可以看到执行的顺序是按照value的值,从1到大

    ------------------------- A little Progress a day makes you a big success... ----------------------------
  • 相关阅读:
    转:PCIe基础知识
    转:HDMI介绍与流程
    Java EJB JBoss
    冒泡排序
    多线程
    快排
    Talk is cheap,show me the code
    oracle union
    Oracle 【to_number】【instr】
    DB 【ACID】
  • 原文地址:https://www.cnblogs.com/qianjinyan/p/14346114.html
Copyright © 2011-2022 走看看