TestNG Tutorial

What is TestNG?

Like JUnit, TestNG is also used as a Java framework for writing repeatable tests. When uses with Selenium, helps integrating various modules implemented under any automation framework For Exmaple, we have a code which reads the xls file, 2nd code that creates the database connectivity, 3rd code that generates the HTML reports and 4th code that generates some logs and there are other Java files written for performing various operations like database handling, generating test results etc.

Now we have a controller placed in between these codes which will maintain the flow of execution i.e. a framework JUnit or TestNG If we want to run all these scripts in single execution then we need a controller which will going to handle all these executions sequentially using differnt JUnit annotations.

Training will be provided on both TestNG and JUnit Java framework since there are some companies that are using JUnit and some are on TestNG.

How to configure TestNG in Eclipse?



Getting Started with TestNG:

  • Go to TestNG Download page

  • Copy the link mention against your Eclipse version

  • In eclipse, Go to help and install new software

To make sure that TestNG is installed in your eclipse go to:

Windows -> Show View -> Other and then expand the Java folder. Here you will get the TestNG option which means that the TestNG is successfully installed and configured inside your eclipse.

So Junit comes embedded with Eclipse where as you need to install TestNG in Eclipse


Some of the TestNG Annotations:

@BeforeSuite
@BeforeMethod
@AfterMethod
@DataProvider
@BeforeClass
@BeforeTest
@AfterClass
@AfterTest
@AfterSuite