zoukankan      html  css  js  c++  java
  • pytest---用例执行顺序

    一、不同文件的执行顺序

     按照目录文件名顺序执行,目录结构如下:

    用例执行顺序:

    二、同一文件下的执行顺序

    按照用例顺序从上到下执行,示例代码:

    import pytest
    
    
    class TestF():
        def testz(self):
            print('testz')
    
        def test3(self):
            print('test3')
    
    def test2():
        print('test2')
    
    def test1():
        print('test1')
    
    def testb():
        print('testb')
    
    def testa():
        print('testa')
    
    if __name__ == '__main__':
        pytest.main()

    执行结果:

    三、改变用例执行顺序

    pip install pytest-ordering

    示例代码:

    import pytest
    
    
    class TestF():
        def testz(self):
            print('testz')
    
        def test3(self):
            print('test3')
    
    def test2():
        print('test2')
    
    def test1():
        print('test1')
    
    @pytest.mark.run(order=2)
    def testb():
        print('testb')
    
    @pytest.mark.run(order=1)
    def testa():
        print('testa')
    
    if __name__ == '__main__':
        pytest.main()

    执行结果(对比二中的执行结果)

  • 相关阅读:
    win10安装mysql5.7.20解压版
    mvn snapshot
    git SSH key
    Grails踩坑记
    oracle数据库中使用hibernate生成表不能正确创建表
    有些人
    制定短期计划(3月9-4.29)
    有些话
    Linux中mysql主从复制
    Linux下安装mysql
  • 原文地址:https://www.cnblogs.com/canghai1024/p/13560164.html
Copyright © 2011-2022 走看看