gpt4 book ai didi

java - NoClassDefFoundError : org/testng/TestNG

转载 作者:塔克拉玛干 更新时间:2023-11-03 03:13:54 28 4
gpt4 key购买 nike

这个错误

NoClassDefFoundError: org/testng/TestNG

当我尝试使用 IntelliJ IDEA 从 Testng.xml 文件运行我的测试时出现。一个一个地运行我的测试以及运行指向 testng.xml 的整个 gradle 项目都非常有效,比如 grade core-test:test

(在我的项目中,我使用的是 Appium + IntelliJ + TestNG)

但是当我使用 IntelliJ 运行 testng.xml 时,我在按下运行后立即收到此消息:

Exception in thread "main" java.lang.NoClassDefFoundError: org/testng/TestNG
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:120)
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:498)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

Caused by: java.lang.ClassNotFoundException: org.testng.TestNG
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)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 18 more

最佳答案

我在此处找到了一个解决方案:https://intellij-support.jetbrains.com/hc/en-us/community/posts/206597869-Cannot-launch-NGTest-runner-in-IntelliJ-IDEA-2016-1

I got it to work by selecting "In whole project" (I had "In single module" selected) under the Configuration tab in the TestNG "Run/Debug Configurations."

However, the prior configuration worked in IntelliJ IDEA 15, so to me, it seems that it may have come from a breaking change with newer IDE.

它对我有用。

关于java - NoClassDefFoundError : org/testng/TestNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39643424/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com