我已经安装了Java语言支持扩展并导入了TestNG jar,但是在VS代码中运行Test时,Java Test Runner控制台中会打印以下错误
{"name":"error","attributes":{"message":"Exception happens in the Test Runner.","trace":"java.lang.NoClassDefFoundError: com/beust/jcommander/ParameterException
at com.microsoft.java.test.runner.testng.TestNGRunner.run(TestNGRunner.java:33)
at com.microsoft.java.test.runner.testng.TestNGLauncher.execute(TestNGLauncher.java:32)
at com.microsoft.java.test.runner.Launcher.main(Launcher.java:57)
Caused by: java.lang.ClassNotFoundException: com.beust.jcommander.ParameterException
at java.net.URLClassLoader.findClass(URLClassLoader.java:382)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 3 more
"}}.
我尝试检查launch.json,也尝试重新安装扩展程序,但没有任何效果。
public class Test_2 {
@Test
void setup()
{
System.out.println("Setup");
}
}
答案 0 :(得分:0)
对于maven,请确保在构建路径中包含jcommander jar:
<!-- https://mvnrepository.com/artifact/com.beust/jcommander -->
<dependency>
<groupId>com.beust</groupId>
<artifactId>jcommander</artifactId>
<version>1.27</version>
</dependency>
检查您的lib版本是否确实包含缺少的类“ com.beust.jcommander.ParameterException”,如果不存在,请尝试使用其他版本的lib。