How to create First TestNG script in Eclipse

To work with TestNG, we need to configure the TestNG with Eclipse.

Steps to create a TestNG Project in Eclipse :
1.Goto Eclipse
2.Select File –> New –>Java Project

TestNG-Project-Creation-In-Eclipse
3.Give the name of the project as TestNGDemo

TestNG-Project-Name-Declaration

  1. Click Finish button.

TestNG-Project-Next-Button

  1. New TestNG project has been created.

6.Need to configure the build path.

  1. Right click in the project. Goto Build Path–>Configure Build path

TestNG-Build-Path-Configure

  1. A pop up window will open as below.

TestNG-Build-Path-Display-Popup

9.Click on Add Library tab.

TestNG-Build-Path-Library-Display

  1. Click on Add Library button.

TestNG-Add-Library-Button
11.A pop up will appear asking to select any one library.

TestNG-Pop-Up-To-Select-Library
12.Select TestNG and click Next

TestNG-Library-Selection

  1. A confirmation Pop up will show up.

TestNG-Finish-TestNG-Project

  1. Click Finish and Ok button to complete the TestNG import in Eclipse.

15.Now the TestNG is added to the Java Project.

TestNG-Successful-Installation-In-Eclipse

Steps to Create TestNG classes in Elipse:

  1. Right click on the project(TestNGDemo as created in above process).
    2.Select New — > Other –> TestNG–>TestNG class

TestNG-New-Class-Creation
3.Click Next button

TestNG-New-Class-Next-Creation
4.In the Next window, give /DemoTestNG/src

TestNG-New-Project-Creation
5.Package name as TestNGExamples
6.Class Name as TestNGFirstScript
7.Click finish

TestNG-New-Demo-Finish
8.Observe new TestNG class will be created with default TestNG syntax.

Leave a Comment

Your email address will not be published. Required fields are marked *