zoukankan      html  css  js  c++  java
  • 15、用例依赖

    用例依赖大致分为 测试方法依赖和测试组依赖

    • 测试方法依赖

    目录如下:

     

    DependentMethodsTest.java 代码如下:

    package com.testng.cn;
    
    import org.testng.annotations.Test;
    
    import static org.testng.Assert.assertEquals;
    
    public class DependentMethodsTest {
    
        @Test
        public void testAdd1(){
            assertEquals(3+1, 5);
        }
    
        @Test(dependsOnMethods = {"testAdd1"})
        public void testAdd2(){
            assertEquals(3+2, 5);
        }
    }
    

    dependsOnMethods 来设置用例的依赖, 当 testAdd1() 运行失败时, 则 testAdd2() 不再被执行。 

    运行结果如下:

     

     

    • 测试组依赖

     目录如下:

     

     

    DependentGroupsTest.java代码如下:

    package com.testng.cn;
    
    import org.testng.annotations.Test;
    
    import static org.testng.Assert.assertEquals;
    
    public class DependentGroupsTest {
    
        @Test(groups={"funtest"})
        public void testAdd1(){
            assertEquals(3+1, 5);
        }
    
        @Test(groups={"funtest"})
        public void testAdd2(){
            assertEquals(3+2, 5);
        }
    
        @Test(dependsOnGroups = {"funtest"})
        public void testAdd3(){
            assertEquals(3+2, 5);
        }
    }
    

    dependsOnGroups 来设置组的依赖, testAdd1()testAdd2() 同属于于 funtest 组, testAdd3() 依赖于 funtest 组, 该组有中有一条用例运行失败, 则 testAdd3() 不再执行。 

    运行结果如下:

     

  • 相关阅读:
    模板模式创建一个poi导出功能
    vim python和golang开发环境配置
    vim快捷键
    golang聊天室
    goroutine与channels
    Redis中的GETBIT和SETBIT(转载)
    二叉树
    满二叉树与完全二叉树
    拓扑排序
    ZigZag Conversion
  • 原文地址:https://www.cnblogs.com/suim1218/p/8883079.html
Copyright © 2011-2022 走看看