问题
When I attempt to run a sample TestNG class in Eclipse with Java 1.7.0_79 I get the following errror:
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. I uninstalled and did it through the www.beust.com/eclipse site.
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. 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.
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");
}
}
回答1:
Make sure you added the jcommander.jar file to your classpath if you are using a project without maven. Make sure your project structure has a "TestNG" library that has only one testng.jar file inside it.
来源:https://stackoverflow.com/questions/36831030/exception-in-thread-main-error-in-eclipse-when-trying-to-run-testng-class