Order of execution of tests in TestNG

前端 未结 17 2715
情书的邮戳
情书的邮戳 2020-11-27 12:46

How to customize the order of execution of tests in TestNG?

For example:

public class Test1 {
  @Test
  public void test1() {
      System.out.printl         


        
17条回答
  •  一个人的身影
    2020-11-27 13:27

    In TestNG, you use dependsOnMethods and/or dependsOnGroups:

    @Test(groups = "a")
    public void f1() {}
    
    @Test(groups = "a")
    public void f2() {}
    
    @Test(dependsOnGroups = "a")
    public void g() {}
    

    In this case, g() will only run after f1() and f2() have completed and succeeded.

    You will find a lot of examples in the documentation: http://testng.org/doc/documentation-main.html#test-groups

提交回复
热议问题