Im using testng 6.11 and writing tests in the following test class:
public class MyTest{
public int i;
public void init(){
//initialize i
}
@Test
public void test1(){
//test some
}
@Test
public void test2(){
//Here I need fresh value of i as it would be
//right after invocation of init()
//...
//test something else
}
}
Is it possible to make testng run init() method before invocation of each test in a test class?
Annotate init() with @BeforeMethod annotation. See http://testng.org/doc/documentation-main.html#annotations
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With