@BeforeSuite vs @BeforeTest

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


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 {
  public void runOnce() {
    System.out.println("This is the @BeforeSuite method");

  public void runForEachTest() {
    System.out.println("This is the @BeforeTest method");

  public void testOne() {
    System.out.println("This is the testOne method");

  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).