TestNG Introduction :-

--> TestNG is a unit test framework designed for testing needs (developers / Test Engineers). 

--> TestNG is an open source  test automation framework, where NG stands for Next Generation.

--> TestNG inspired from Junit and Nuit but introduced some new functionalities, that made TestNG is more powerfull than Junit and Nuint frameworks.

--> It is designed to cover all categories of tests - Unit, functional, end-to-end, integration, regression, retesting etc.

--> TestNG allows users to do test configuration through XML files and allows them to include (or exclude) respective packages, classes, and methods in their test suite.

  • WebDriver has no native mechanism for generating reports.
  • TestNG can generate reports based on our Selenium test results.
  • TestNG can generate the report in a readable format.
  • There is no more need for a static main method in our tests. 
  • The sequence of actions is regulated by easy-to-understand annotations that do not require methods to be static.
  • Uncaught exceptions are automatically handled by TestNG without terminating the test prematurely and These exceptions are reported as failed steps in the report.

Advantages / Benfits of TestNG Framework :-
--> It is easier to use.
--> It is supported by a variety of tools and plug-ins (Eclipse, IDEA, netbeans, Maven, etc...)
--> Flexible test configuration.
--> It generates HTML test reports.
--> Support for data-driven testing (with @DataProvider).
--> Support for parameters.
--> Support for multi threaded testing.
--> Supports testing integrated classes (e.g., by default, no need to create a new test class instance for every test method).
--> TestNG Annotations are easy to create Test cases.
--> Test cases can be grouped and prioritized more easily.
--> Parlell Testng is possible.
--> Parameterization is possible.
--> We can execute the test cases in the order which we provide using priority.
--> We can run classes without using Main method.
--> Default JDK functions for runtime and logging (no dependencies). 
--> To read the data from Excel file.
--> Supports Dependent test methods is possible.
--> Embeds BeanShell for further flexibility.
--> TestNG is designed to cover all categories of tests:  unit, functional, end-to-end, integration, etc etc..
--> Supports testing integrated classes (e.g., by default, no need to create a new test class instance for every test method).
--> Supported more/different Annotations like 
1) @Test 
2) @BeforeSuite 
3) @AfterSuite 
4) @BeforeClass
5) @AfterClass 
6) @BeforeTest 
7) @AfterTest
8) @BeforeGroups 
9) @AfterGroups 


What is a test suite?

A test suite is a collection of test cases intended to test a behavior or a set of behaviors of software program.
Running a set of test cases together is call executing a Test Suite.
In testNG, a suite is represented by an xml file. A suite can contain one or more tests and is defined by the <suite tag.

Why do we need test suite?

Test suite is to execute multiple test cases at the same time.

We are using test suite is 

  • TestNG Include and Exclude Methods
  • TestNG Groups Test Methods
  • TestNG DataProvider
  • TestNG Cross Browser Testing
  • TestNG Page Object Model
  • TestNG Listeners and etc etc...