Testng eclipse tutorial – Install and use testng eclipse plugin

he TestNG Eclipse plug-in allows that we run TestNG tests from inside Eclipse in a convenient way. once we draft test case then we would’t need waiting, simply run it from Eclipse and monitor the execution and output. This tutorial will guide how to install TestNG eclipse plugin, write and run test case with this plugin.


Eclipse and JDK 5 or higher.

How to install testNG eclipse plugin?

1. Open eclipse, click Help –> Install New Software, in the ‘select a site’ window, click add to open ‘add repository’ dialog.

The TestNG team maintains an latest update in Eclipse update site. we suggest using the following update site address in textbox location to get latest release:

  • For Eclipse 3.4 and higher than, enter http://beust.com/eclipse.
  • For Eclipse 3.3 and below, enter http://beust.com/eclipse1.

2. Once enter name and location, click OK,  then on the ‘Name’ column, select ‘TestNG’ and click ‘Next’ button until appearing the following screenshot.

3. Choose the radio button “I accept the terms of the license agreement” and click finish, it will lead to complete the installation automatically, during this process, if it have security warning, it says that you are installing software that contains unsigned content, please click OK.

4. Click Yes to restart Eclipse to take effect the all changes.

How to Write a TestNG case in eclipse?

1. Create a new project in Eclipse, and add a test class SimpleTestCase.

import java.util.ArrayList;
import java.util.List;
import org.testng.annotations.Test;
import org.testng.Assert;
public class SimpleTestCase {
    private List list;
    public void testEmptyCollection() {
        list = new ArrayList();
        System.out.println("list is empty");

The error occurred as The TestNG library has not yet added to the project, click them to choose ‘Add TestNG library’.

Once done, right-click Run as -> TestNG to run this test case, you will be able to see:

Console output:

[TestNG] Running:
C:\Users\asjava\AppData\Local\Temp\testng-eclipse–494421159\testng-customsuite.xmllist is empty
PASSED: testEmptyCollection===============================================
Default test
Tests run: 1, Failures: 0, Skips: 0
Default suite
Total tests run: 1, Failures: 0, Skips: 0
===============================================[TestNG] Time taken by org.testng.reporters.XMLReporter@13ded59: 379 ms
[TestNG] Time taken by org.testng.reporters.SuiteHTMLReporter@d98b00: 730 ms
[TestNG] Time taken by org.testng.reporters.EmailableReporter2@aed3a5: 157 ms
[TestNG] Time taken by [FailedReporter passed=0 failed=0 skipped=0]: 0 ms
[TestNG] Time taken by org.testng.reporters.jq.Main@faa824: 161 ms
[TestNG] Time taken by org.testng.reporters.JUnitReportReporter@4be8b8: 77 ms
Оцените статью
Добавить комментарий

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

  1. http://google.com

    _Testng eclipse tutorial – Install and use testng eclipse
    plugin_ was indeed a very good blog. However,
    if it possessed much more photos this might be quite possibly even better.

    Cya ,Ashleigh

  2. Anubhav Goel

    Can we install Testng in eclipse offline as well ? it would be great if you can share this solution also.

  3. vicky

    Does this plugin work with eclipse luna 4.4.2 ?