TestNG Installation in Eclipse — 1

Beginner | Refresher

Tushar Patil
2 min readJan 17, 2022

About TestNG: It’s a framework for unit tests. Inspired by JUnit. Provides better reporting options and additional annotations.

Step1: Download TestNG Plugin. Get it from Eclipse marketplace or testng.org

TestNG eclipse installation

Installation was aborted because it is already installed on the machine. (If security alert pop-ups click on the install anyway option as it appears on screen)

Step2: Verify the TestNG installation in Eclipse.

  • Click window in menu bar → show view → other → java folder → check if TestNG appears
  • Or click on a file in menubar → new → other → search for TestNG

Step3: Create a maven project or simple java project

testng example
  • It’s about annotations so don't panic, until you mention “@Test” it won’t consider a method as a test case. Each test case needs this annotation.
  • Create class file and add the code below in file

@Test //you see error → import testng
public void verifyMyFirstTestNGRun(){
System.out.println(“Running…”);
}

  • Now, save the file and run the project as TestNG. You should see the pass to 1 fail to 0 and skip 0 in the console.
  • Note: @Test indicates a test case. N @Test annotations are your n test cases.

Note: if 7.0.0 is not working upgrade or downgrade to other versions.

Step 4: Reports →After test execution gets completed, go to the project pane and find the test-output folder. Not seeing rerun or refresh the project. Expand it there are test report files named like the index, emailable report, etc… Click and see the test report.

Hope this was helpful. Thanks!

--

--