TestNG & Selenium: Separate tests into “groups”, run ordered inside each group

后端 未结 3 1554
说谎
说谎 2021-01-02 21:30

We use TestNG and Selenium WebDriver to test our web application.

Now our problem is that we often have several tests that need to run in a certain order, e.g.:

3条回答
  •  滥情空心
    2021-01-02 21:35

    Try with depends on group along with depends on method. Add all methods in same class in one group. For example

    @Test(groups={"cls1","other"}) 
    public void cls1test1(){
    }
    @Test(groups={"cls1","other"}, dependsOnMethods="cls1test1", alwaysrun=true) 
    public void cls1test2(){
    }
    
    In class 2
    @Test(groups={"cls2","other"}, dependsOnGroups="cls1", alwaysrun=true) 
    public void cls2test1(){
    }
    @Test(groups={"cls2","other"}, dependsOnMethods="cls2test1", dependsOnGroups="cls1", alwaysrun=true) 
    public void cls2test2(){
    }
    

提交回复
热议问题