@BeforeClass and inheritance - order of execution

前端 未结 16 2059
梦如初夏
梦如初夏 2020-12-02 11:39

I have an abstract base class, which I use as a base for my unit tests (TestNG 5.10). In this class, I initialize the whole environment for my tests, setting up database map

16条回答
  •  萌比男神i
    2020-12-02 12:22

    I added public to the abstract class and TestNG (6.0.1) executed the doInitialization() before doTests. TestNG does not execute doInitialization() if I remove public from class A.

    public abstract class A {
     @BeforeClass
     doInitialization() {...}
    }
    
    class B extends A {    
     @Test
     doTests() {...}
    }
    

提交回复
热议问题