Can anyone please say me the exact difference between @Beforesuite and @BeforeTest? Explain when and where to use each of the one.
This is Appium forum. It has nothing to do with configuration method of TestNG/Junit. Please refer their respective forums
Thanks
Before suite will run only once when you run a suite
Before test will run for all the test script written inside the suite
public class ExampleTest {
@BeforeSuite
public void runOnce() {
System.out.println("This is the @BeforeSuite method");
}
@BeforeTest
public void runForEachTest() {
System.out.println("This is the @BeforeTest method");
}
@Test
public void testOne() {
System.out.println("This is the testOne method");
}
@Test
public void testTwo() {
System.out.println("This is the testTwo method");
}
}
Try running this and see what happens. It’ll give some initial insight into how BeforeSuite is different from BeforeTest.
Additionally, methods tagged with BeforeSuite will run before test methods in OTHER classes of the test suite (assuming you only have 1 test suite).