[英]Exception in thread “main” Error in Eclipse when trying to run TestNG class
When I attempt to run a sample TestNG class in Eclipse with Java 1.7.0_79 I get the following errror: 当我尝试使用Java 1.7.0_79在Eclipse中运行示例TestNG类时,我得到以下错误:
Exception in thread "main" com.beust.jcommander.ParameterException: Unknown option: -protocol
at com.beust.jcommander.JCommander.parseValues(JCommander.java:742)
at com.beust.jcommander.JCommander.parse(JCommander.java:282)
at com.beust.jcommander.JCommander.parse(JCommander.java:265)
at com.beust.jcommander.JCommander.<init>(JCommander.java:210)
at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:162
I have tried installing TestNG through the Eclipse store, when that didn't work. 我尝试通过Eclipse商店安装TestNG,但这不起作用。 I uninstalled and did it through the www.beust.com/eclipse site.
我卸载并通过www.beust.com/eclipse网站完成。
My class doesn't show any errors, but my project does have a question mark in the lower-left part of the image. 我的班级没有显示任何错误,但我的项目在图像的左下角确实有一个问号。
I thought it was because I was missing the jcommander.jar. 我以为是因为我错过了jcommander.jar。 So I've even gone and tracked that down and included it in my libraries.
所以我甚至已经把它追踪并将其包含在我的库中。
The weird thing is, is that I am running the same configurations on my Windows PC and was able to get TestNG scripts running, but when I go through the same setup on my Mac, I get the error. 奇怪的是,我在Windows PC上运行相同的配置并且能够运行TestNG脚本,但是当我在Mac上进行相同的设置时,我收到错误。
This is the code I'm trying to run: 这是我正在尝试运行的代码:
import org.testng.annotations.Test;
public class NewTest {
@Test
public void testMethod() {
System.out.println("First TestNG test");
}
}
Make sure you added the jcommander.jar file to your classpath if you are using a project without maven. 如果您使用的是没有maven的项目,请确保将jcommander.jar文件添加到类路径中。 Make sure your project structure has a "TestNG" library that has only one testng.jar file inside it.
确保您的项目结构具有“TestNG”库,其中只有一个testng.jar文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.