Let’s start with some questions :-
I have installed TestNG but I am not getting TestNG annotation. Why?
I have added TestNG jar but not getting an option to run test as a TestNG test in Eclipse. Why?
You must have heard or faced the above questions. The reason behind these is that You may not get the “What and Why” of TestNG Jar and TestNG plugin.”.
TestNG Jar :-
TestNG jar is a Test framework which allows you to do a lot of things like creating tests, creating configuration methods, running tests, parallel execution, data driven testing , reporting and many more. To use these features you MUST need to add TestNG dependency in Maven or Gradle project or download JAR and add to project build path. After that only you will be able to use different annotation provided by TestNG.
TestNG Plugin :-
When you create some test, by default you do not get option to run test as a TestNG test in Eclipse as shown below:-
To run the test as TestNG test, you need TestNG Plugin. You can install TestNG plugin from Eclipse Market place or Install New Software in Eclipse.
Note :- You do not need TestNG plugin in IntelliJ as TestNG is bundled in IntelliJ IDEA.
You can find step by step tutorial to install TestNG plugin in eclipse here.
If you have any doubt, feel free to comment below.
If you like my posts, please like, comment, share and subscribe.
#ThanksForReading
#HappyLearning
You can find all Selenium related post here.
You can find all API manual and automation related posts here.
You can find frequently asked Java Programs here.
We need both TestNG dependency(POM.xml) and plug-in (build path) to our project
Hi, so when ever we use TestNG functionality we have to add TestNG dependency to POM.xml and also add TestNG plugin to project build path. Both we have to do.
hi Amod. I am a little confused here.
first i installed testng plugin in eclipse and i was able to add TestNG annotations and run TestNG class. Also, i saw TestNG.jar file in TestNG folder created. however, when tried creating a xml file using Convert to TestNG class, no xml is created.
so i have two queries:
1) if we install testng from plugin from eclipse marketplace, is there a need to install testNG jar file separately ( as i can see jar file in TestNG library foler)
2) what can i do to create testng.xml file?
Thanks,
Sapna
Hi, you would have TestNG library earlier that’s you would be getting that. But both are two different thinhs.
Hi Amod,
That was a nice tip. Addition to this if an organization has blocked software installing from market place. There is a work around wherein we can put the testng.jar file in the dropins folder found inside the eclipse folder.
Should close and reopen the eclipse and you can now find the option RunAs Testng.
You are making same mistake again. You don’t download TestNG jar from Market place. Its TestNG plugin for eclipse. If downloading is blocked from market place, you can download from url and place in dropin folder.