AdityaK
AdityaK

Reputation: 339

TestNG option not showing in RunAs option in Eclipse

I am using maven project in eclipse ide and added a testng dependency as:

<dependency>
        <groupId>org.testng</groupId>
        <artifactId>testng</artifactId>
        <version>6.8.8</version>
        <scope>test</scope>
    </dependency>

but i am unable to see TestNg option when right click on any testclass

Upvotes: 12

Views: 153657

Answers (14)

Nishant Bodade
Nishant Bodade

Reputation: 21

I was facing the same issue. I had to delete the TestNG Maven dependency in my local .m2 folder and update the Maven project again, after which Eclipse was able to detect TestNG and display it in the ‘Run As’

Upvotes: 0

Siddharth Mittal
Siddharth Mittal

Reputation: 119

I Got the Solution

Adding just testng dependency in pom.xml is not enough You need to also install the software

Follow the steps

  1. Open eclipse
  2. Go to Help
  3. Then Go to Install New Software
  4. Then in search bar type https://testng.org/testng-eclipse-update-site & hit enter enter image description here

Upvotes: 1

DarkShadows
DarkShadows

Reputation: 45

i've spend whole day to figuring it out what was causing this testNG option suddenly disappared from eclipse , possibility due to recent updating the eclipse version or its something causes due to uninstalling that darkest dev theme with devstyle.

Tried several solutions mentioned above and none of them works for me then this morning just uninstalled my eclipse, restarted PC and downloaded the new eclipse and have reopened the same projects which works fine for me, absolutely no issues with it. (don't forget to install testNG from marketplace first)

For those who has tried all above solutions and still troubling to get TestNG option, Well here i would like to suggest you try to follow these steps to get testNG option back into eclipse.

Upvotes: 0

Avnish Rathore
Avnish Rathore

Reputation: 99

Select Help / Install New Software... Enter the update site URL in "Work with:" field: Update site for release: https://dl.bintray.com/testng-team/testng-eclipse-release/. Make sure the check box next to URL is checked and click Next.

Upvotes: 2

Mohit Garg
Mohit Garg

Reputation: 25

Make sure you are not using JUnit.

You should not use :
import org.junit.Test;
You should use:
import org.testng.annotations.Test;

Upvotes: 0

Atishay Jain
Atishay Jain

Reputation: 117

I am working on TestNG in Eclipse, I have added maven dependency using maven:

<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
</dependency>

When I tried to run my test file present in src/java/test folder, I can't see anything in RunAs, then I followed below steps:

Goto Help->Install new Software-> Click on Add button->

  1. Name= TestNG
  2. Location=https://dl.bintray.com/testng-team/testng-eclipse-release/7.1.0/

NOTE: 7.1.0 is my TestNG version, you can change this to your version.

It will show you TestNG -> Check it and install it -> Restart Eclipse. Now you can see TestNGTest option in your Run As option.

For more information, check README file in GitHub Repo: https://github.com/cbeust/testng-eclipse

Upvotes: 4

Sugat Shivsharan
Sugat Shivsharan

Reputation: 595

I too was facing the same problem, here is what worked for me

  1. Add TestNG dependency in Maven.

  2. Add Eclipse plugin as shown in link : https://www.toolsqa.com/selenium-webdriver/install-testng/

It will take some time to add the plugin. Run the test after the Eclipse restarts.

Upvotes: 0

Vijay Aaditya
Vijay Aaditya

Reputation: 1

I faced a similar issue this morning and I followed the below steps to get it resolved.

  1. Add TestNG library to Java Build Path
  2. The TestNG Class should have been created under src/test/java.

In my case, I had it created under src/main/resources which is why I reckon it had no run configuration. This confusion arose because I normally use simple project but this time I wanted to learn by selecting an archetype.

Upvotes: 0

Rajesh Thakur
Rajesh Thakur

Reputation: 189

If in Run->Run configuration you can't able to see TestNG Pluin then First add TestNG plugIn and install it. You can follow the following steps Eclipse->Help->Install New Software->Add->Give Name As TestNG->put URL(http://beust.com/eclipse/)->Click Install

Upvotes: 1

check if the annotation @Test is missing before the actual test method.

Upvotes: 1

Rocky
Rocky

Reputation: 11

This is the simple solution that worked for me. Just Add Library of TestNG.

Right click on your project > Configure Build Path > Add Library > TestNG > Next, Next, Finish.

Upvotes: 1

Greg
Greg

Reputation: 4045

Ensure you have at minimum Java JDK 7, which is required for TestNG. See requirements section of testng documentation.

If you have Java 1.6 or earlier, it won't load in Eclipse, you can figure this out by looking at the [workspace]/.metadata/.log file, you should see the error logged:

!ENTRY org.testng.eclipse 4 0 2015-08-16 06:36:21.383
!MESSAGE FrameworkEvent ERROR
!STACK 0
org.osgi.framework.BundleException: Could not resolve module: org.testng.eclipse [432]
  Unresolved requirement: Require-Capability: osgi.ee; filter:="(&(osgi.ee=JavaSE)(version=1.7))

Upvotes: 2

user3821521
user3821521

Reputation:

After you have installed TestNG eclipse plugin, you need to create a TestNG run configuration. From the menu bar select: Run > Run Configurations. Select 'TestNG' from the list and select 'New Lanuch Configuration'. In there select class, method, whatever you want to run.

You can also go to preferences > run/debug > launching and select your default launch configs (launch the selected resource or active editor). enter image description here

Upvotes: 1

Michał Grzejszczak
Michał Grzejszczak

Reputation: 2617

That dependency alone is hardly enough. You need to install TestNG Eclipse plugin to be able to use it as you describe.

Upvotes: 10

Related Questions