After upgrading to Intellij 15 TestNG tests don't run in the IDE
Asked Answered
B

3

11

I upgraded my community edition IntelliJ from version 14 to 15.0.1 and TestNG tests which used to run in the IDE give these exceptions. How do I fix these?

Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/CommandLineArgs
    at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:118)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:497)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)
Caused by: java.lang.ClassNotFoundException: org.testng.CommandLineArgs
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)

Let me know if more information is needed.

Bradlybradman answered 25/11, 2015 at 1:4 Comment(5)
Sounds like a classpath issue. I'm betting that they'll run if you add TestNG to your test classpath. Not an IntelliJ problem; a project configuration problem.Drysalter
I don't believe it is an configuration issue as the same is working with Intellij14Bradlybradman
Note that this is on Amazon Linux.Bradlybradman
Find this class in your testng.jar: org.testng.CommandLineArgs. Is it there?Drysalter
I'm guessing that IntelliJ 15 expects a different version of the TestNG JAR that contains the class org.testng.CommandLineArgs, but your project doesn't have it.Drysalter
F
10

The org.testng.CommandLineArgs class was introduced in TestNG 6.0. I encountered the same problem and my project had TestNG 5.9. After upgrading to a newer version tests ran successfully.

Frisk answered 25/11, 2015 at 17:56 Comment(1)
I have Idea 2016.2 Community. Adding <dependency> <groupId>org.testng</groupId> <artifactId>testng</artifactId> <version>6.8.5</version> <scope>test</scope> </dependency> to my pom helped.Smother
B
0

What worked for me was adding the testng-remote dependency explicitly to my project. In my pom.xml I have these 2 dependencies:

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

    <dependency>
        <groupId>org.testng.testng-remote</groupId>
        <artifactId>testng-remote</artifactId>
        <version>1.4.0</version>
        <scope>test</scope>
    </dependency>

Note that testng-remote is not in the maven central repository. You need to add this repository to your pom.xml as well:

<repositories>
    <repository>
        <id>testng</id>
        <url>https://dl.bintray.com/testng-team/testng/</url>
    </repository>
</repositories>

Hope this helps someone out there.

Bluebill answered 8/2, 2019 at 3:3 Comment(0)
C
-2

adding

<dependency>
    <groupId>com.github.adedayo.intellij.sdk</groupId>
    <artifactId>testng_rt</artifactId>
    <version>142.1</version>
</dependency>

to my pom, fix the problem.

Chant answered 25/5, 2016 at 19:12 Comment(1)
It didn't for me.Joker

© 2022 - 2024 — McMap. All rights reserved.