TheDeveloperBlog.com

Home | Contact Us

C-Sharp | Java | Python | Swift | GO | WPF | Ruby | Scala | F# | JavaScript | SQL | PHP | Angular | HTML

TestNG @BeforeSuite Annotation

TestNG @BeforeSuite Annotation with Testng Tutorial, Introduction, Testng Installation, Features of Testng, Suite Test, Testng Exception Test, Group Test, Plug with Ant, Plug with Eclipse, etc.

<< Back to TESTNG

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., Car_loan.java, Home_loan.java, and Personal_loan.java.

Car_loan.java

package com.TheDeveloperBlog;
import org.testng.annotations.Test;
public class Car_loan 
{
@Test
 public void car_loan()
 {
	 System.out.println("Car Loan");
 }
}

Home_loan.java

package com.TheDeveloperBlog;

import org.testng.annotations.Test;

public class Home_loan 
{
@Test
public void home_loan()
{
  System.out.println("Home Loan");
}
}

Personal_loan.java

package com.TheDeveloperBlog;
import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class Personal_loan
{
 @Test
 public void personal_loan()
 {
	 System.out.println("Personal Loan");
 }
 @BeforeSuite
 public void before_suite()
 {
	 System.out.println("First method");
 }
}

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 Personal_loan.java 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.

Output

TestNG @BeforeSuite Annotation
Next TopicTestNG Annotations




Related Links:


Related Links

Adjectives Ado Ai Android Angular Antonyms Apache Articles Asp Autocad Automata Aws Azure Basic Binary Bitcoin Blockchain C Cassandra Change Coa Computer Control Cpp Create Creating C-Sharp Cyber Daa Data Dbms Deletion Devops Difference Discrete Es6 Ethical Examples Features Firebase Flutter Fs Git Go Hbase History Hive Hiveql How Html Idioms Insertion Installing Ios Java Joomla Js Kafka Kali Laravel Logical Machine Matlab Matrix Mongodb Mysql One Opencv Oracle Ordering Os Pandas Php Pig Pl Postgresql Powershell Prepositions Program Python React Ruby Scala Selecting Selenium Sentence Seo Sharepoint Software Spellings Spotting Spring Sql Sqlite Sqoop Svn Swift Synonyms Talend Testng Types Uml Unity Vbnet Verbal Webdriver What Wpf