Javatpoint Logo
Javatpoint Logo

TestNG @BeforeSuite Annotation

Till now, we read about the @BeforeTest and @AfterTest which have control over the particular folder not on the entire framework. The tag has control over the whole XML file. The tag is the parent of all the test folders.

@BeforeSuite: The @BeforeSuite annotated method is executed before the execution of all the test cases defined in the folder.

Generally, @BeforeSuite is used when we have different URLs to run your test cases. Environment variables are set in a @BeforeSuite annotated method so that before executing all the test cases, you need to load all the environment variables for your framework, and then it starts executing your test cases.

The @BeforeSuite annotated method is given as the first priority, so it is executed before all the other test methods.

Let's understand the @BeforeSuite annotated method through an example.

Step 1: Open the Eclipse.

Step 2: We create three modules of loan, i.e.,,, and

Step 3: Create testng.xml file to configure classes.

testng.xml file

We created three modules of loan, i.e., Car loan, Personal loan, and Home loan. Their class files are configured in the testng.xml file. The @BeforeSuite annotated method is defined in the file which means that @BeforeSuite annotated method, i.e., before_suite() is executed first before all the test methods available in configured classes in the XML file. According to the testng.xml file, TestNG will first execute the before_suite() method and then TestNG will follow the sequence of folder.

Step 4: Run the testng.xml file. Right click on the testng.xml, and then move down to the Run As, click on the 1 TestNG Suite.


TestNG @BeforeSuite Annotation
Next TopicTestNG Annotations

Youtube For Videos Join Our Youtube Channel: Join Now


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Trending Technologies

B.Tech / MCA