TestNg's @BeforeTest on base class only happening once per fixture

前端 未结 4 564
名媛妹妹
名媛妹妹 2020-12-09 08:06

I\'m trying to use @BeforeTest to get code to ... run once before every test.

This is my code:

public class TestBase {
    @BeforeTest
    public voi         


        
4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-09 08:30

    According to documentation, a method annotated with @BeforeTest is run before any @Test method belonging to the classes inside the tag is run.

    From my experience:

    • Each @BeforeTest method is run only once
    • If you have several @BeforeTest methods, the order of their execution depends on the order of the class containing those @BeforeTest method.

    You could test this by setting up a simple example.

提交回复
热议问题