Difference between BeforeClass and BeforeTest in TestNG

后端 未结 7 2198
旧巷少年郎
旧巷少年郎 2020-11-28 05:00

As we know from official TestNG documentation:

@BeforeClass: The annotated method will be run before the first test method in the current class is invok

相关标签:
7条回答
  • 2020-11-28 06:03

    if you extend from another class this are the results:

    parentTest - BeforeTest- parent     
    testClass1 - BeforeTest- test1    
    parentTest - BeforeClass- parent    
    testClass1 - BeforeClass- test1    
    parentTest - BeforeMethod- parent    
    testClass1 - BeforeMethod- test1    
    testClass1 - myTestMethod1    
    testClass1 - AfterMethod- test1    
    parentTest - AfterMethod- parent    
    parentTest - BeforeMethod- parent    
    testClass1 - BeforeMethod- test1    
    testClass1 - myTestMethod2    
    testClass1 - AfterMethod- test1    
    parentTest - AfterMethod- parent
    testClass1 - AfterClass- test1    
    parentTest - AfterClass- parent
    testClass1 - AfterTest- test1
    parentTest – AfterTest- parent
    
    0 讨论(0)
提交回复
热议问题