简体   繁体   中英

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:

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");
  }
}

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM