In last post, we have seen the requirements of TestNG in Selenium webdriver. We will learn how can we install TestNG in eclipse.
TestNG is a jar file. Any JAR file stands for Java ARchive which is a package file format typically used to aggregate many Java class files and associated metadata and resources (text, images, etc.) into one file for distribution.
We can install TestNG in different ways given below:
- Download and add to build path.
- Using market place
- Using Install New Software option of Eclipse
- Using Maven’s pom.xml
- Using Gradle
Above ways are scenario dependent and I will explain when and which way to follow.
Download and add to build path:
- If you are using a normal Java project or I can say more specifically, if you are not using Maven or Gradle project.
- Sometimes you will find that TestNG is not getting installed using Market place and Install New software options. In that case also, you can use this way.
You can download TestNG jar files from below sites:
Some direct link I can give you below:
Major disadvantage of using this approach is that you may or may not get the latest version of TestNG and also any upgrade need manual effort to download and add again to build path. Remember you must remove old version from build path.
Steps to follow:
- Download TestNG jar file from any of the above sites. You will get a zip file which will have jar file inside.
- Unzip the Zip file and copy jar file.
- Create a folder (Say jarFIles) within project and paste jar file in that folder. You can just use normal copy paste command to do this.
4. Now you need to ad dthis jar file in to build path, so that Java Compiler will be aware of this. To add into build path, right click on testng jar file and Mouse hover on Build Path and select “Add to build path”.
Right Click —> Build Path —>Add To Build Path
5. Once you add jar file into build path, you can verify it by checking in “Referenced Libraries” folder. Expand it and you should see tesng.jar file in that.
6. You can also verify correct installation by using any one of the tag ( @Test etc) in any script. When you type @Test and mouse hover on it, you can see options to import it from TestNG package.
We will see other ways in upcoming posts.
More about TestNG in upcoming posts. Stay tuned.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
Author: Amod Mahajan
My name is Amod Mahajan and I am an IT employee with 6+ years of experience in Software testing and staying in Bengaluru. My area of interest is Automation testing. I started from basics and went through so many selenium tutorials. Thanks to Mukesh Otwani as his tutorials are easy and cover basics to advance. I have habit of exploring concepts by deep diving. I used to make notes. I thought of sharing my knowledge through posts and now I am here. #KeepLearning #ShareLearning