This Detailed Tutorial Explains All About Integration of TestNG in Eclipse. It Also Shows How to Find Other Plugins Through the Marketplace and Install Them:
In this In-Depth Eclipse Training Tutorials For All, we learned about Configuring Maven and SVN with Eclipse in our previous tutorials.
These tools will help manage your code. However, as a tester, there is one tool that you must have configured in Eclipse i.e. TestNG, it is one of the most powerful add-ons for test engineers creating an automation framework.
This tutorial will talk about how you can get and use TestNG in your Eclipse Java IDE. Eclipse has a marketplace as well, from where you can search for more plugins and install them directly on your IDE for your use.
Table of Contents:
What Is TestNG?
TestNG is a testing framework that works with Java. It is a framework that is built on Junit. Junit is used more by developers for writing unit test cases, whereas TestNG is used by testers for creating flexible and manageable automation frameworks. Before using TestNG to create a framework, you must configure it with your IDE.
To do that, you need to follow the below steps:
#1) On the top menu of Eclipse navigate to Help -> Install New Software.
By clicking on the add button in the dialogue box that appears, add name and location depending on the version of SVN that you want to install as shown below:
Name: TestNG
Location: http://beust.com/Eclipse
#2) Eclipse will fetch the required information.
#3) Once the fetch is completed, select TestNG in the checkbox and click next.
#4) Eclipse will show the features being installed, click on next.
#5) Eclipse will ask you to accept the terms of the agreement.
Click on the radio button to accept and click on finish.
#6) Eclipse will start the installation and you can see the progress at the bottom of the IDE.
If you encounter any alerts during the installation, then you can click ok. As soon as the installation is over, Eclipse will ask you to restart.
Once you restart, you can see that TestNG is installed by navigating to Windows -> Preferences.
Converting an Existing Project to TestNG Project
To convert an existing project to a TestNG project, right-click on the project folder from the project explorer and navigate to TestNG -> Convert to TestNG.
Eclipse will prompt you to create a testing.xml file as shown below.
Eclipse will automatically give all the default features in the XML file. You can change these from this window or go with the default and click on next and finish.
Once you finish, you will see that the XML file is added to your project folder.
You can now use TestNG to create the framework that you are working on.
Adding a TestNG Class to Your Project
If you have a TestNG project and if you want to add a new class with TestNG features, then you can do the same.
Simply right-click on the package that you want to add class to and click on New -> Other.
Select TestNG class and click on next.
The basic annotations provided by TestNG are given here, you can select what you need and create a structured class without having to manually add these annotations to the code.
With these features, you can use TestNG to improve your framework better.
Other Plugins
Like the few plugins or tools, we have seen so far, many more plugins that can be integrated with Eclipse. To view all the plugins available for integration, navigate to the top menu of Eclipse and click on Help -> Eclipse Marketplace.
The following window will open:
When you scroll to the bottom of the list, you will find a link to browse for more solutions.
This will open the marketplace as a web page on the Eclipse IDE itself.
If you expand the page, you can browse through many plugins with an install link present next to each of them. You can simply click on the install button and the required plugin will be installed in your IDE.
Summary
In this tutorial, we have learned about integrating some important tools with Eclipse.
- Integrating TestNG with Eclipse.
- How to find plugins through the marketplace and install them.
With this Java Eclipse tutorial series, we have shared all the important details that you must know while using Eclipse. Eclipse is a very vast tool with many features. The more you dig deeper the more you will discover. However, with this set of tutorials, we have tried to give you a strong base from where you can start and learn more.
We hope you enjoyed this informative Eclipse Training Tutorial Series!!
PREV Tutorial | FIRST Tutorial