I'm trying to use @BeforeTest to get code to ... run once before every test.
This is my code:
public class TestBase {
@BeforeTest
public void before() {
System.out.println("BeforeTest");
}
}
public class TestClass extends TestBase{
@Test
public void test1(){}
@Test
public void test2(){}
}
"BeforeTest" is only printed once, not twice. What am I doing wrong?
Use @BeforeMethod, not @BeforeTest.
The meaning of @BeforeTest is explained in the documentation.