TestNG conditional configuration methods

后端 未结 2 1816
心在旅途
心在旅途 2021-01-17 04:39

I would like to know if there is a way of having different configuration methods (let\'s say at class level, @Before/AfterClass) that will enable the user to select which co

2条回答
  •  生来不讨喜
    2021-01-17 05:33

    Depending on your test setup you might just use groups:

    public class Test {
    
      @BeforeClass(groups = {"A"})
      public void configuration1() {...}
    
      @BeforeClass(groups = {"B"})
      public void configuration2() {...}
    
      @Test(groups = {"A", "B"})
     public void testFoo() {...} 
    
      @Test(groups = {"A"})
      public void testFoo() {...} 
    }
    

    Or you might think about parameterizing your tests/use data providers.

提交回复
热议问题