TestNG option not showing in RunAs option in Eclipse
Asked Answered
M

13

12

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

Manuscript answered 13/7, 2015 at 13:33 Comment(0)
S
10

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

Schuck answered 13/7, 2015 at 14:31 Comment(3)
Thanks Michal.but i have already downloaded the plugin and remove dependencies from pom.xml but still it is not visibleManuscript
I think you need to keep the dependency in your project. Otherwise the tests will not compile. Post an example test of yours.Convexoconvex
Even after installing plugin, I don't see option Run As ? I have class which extends AbstractTestNGCucumberTests.Inosculate
C
4

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

Ciapas answered 1/5, 2020 at 5:3 Comment(2)
This is what error I am getting when I am trying above step: HTTP Server 'Bad Gateway' : dl.bintray.com/testng-team/testng-eclipse-release/6.9.5/… HTTP Server 'Bad Gateway' : dl.bintray.com/testng-team/testng-eclipse-release/6.9.5/… HttpComponents connection error response code 502.Barnaul
Now, you can install from eclipse Marketplace, I am using eclipse version:Eclipse IDE for Java Developers (includes Incubating components) Version: 2022-03 (4.23.0) Build id: 20220310-1457Ciapas
B
2

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))
Berte answered 16/8, 2015 at 14:13 Comment(1)
Thank you! That solved it for me. I had jdk 6.0 set in Window > Preferences > Java > Installations. Switched to jdk 8, and changed the vm parameter in eclipse.ini.Lenity
N
2

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.

Nighttime answered 30/6, 2020 at 3:43 Comment(0)
I
1

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

Ibarra answered 13/7, 2015 at 18:28 Comment(0)
C
1

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.

Cardiovascular answered 5/10, 2018 at 12:9 Comment(0)
C
1

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

Coopersmith answered 20/11, 2018 at 8:56 Comment(0)
A
1

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

Acre answered 12/3, 2019 at 1:54 Comment(1)
URL is no more valid replace it with - dl.bintray.com/testng-team/testng-eclipse-releaseTerrify
L
0

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.

Lucillalucille answered 2/6, 2019 at 8:42 Comment(0)
Y
0

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.

Yeh answered 22/1, 2020 at 7:49 Comment(0)
P
0

Make sure you are not using JUnit.

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

Pyszka answered 19/6, 2020 at 13:7 Comment(0)
O
0

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.

Outpour answered 22/9, 2022 at 9:37 Comment(0)
G
0

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
Gesticulative answered 28/4 at 8:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.