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.
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.
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:
C:\Users\asjava\AppData\Local\Temp\testng-eclipse–494421159\testng-customsuite.xmllist is empty
Tests run: 1, Failures: 0, Skips: 0
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