3

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");
  }
}
juherr
  • 5,640
  • 1
  • 21
  • 63
Tom
  • 89
  • 1
  • 9

1 Answers1

4

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.

sebenalern
  • 2,515
  • 3
  • 26
  • 36
  • I may have had multiple testng libraries, I know that my JRE environment had a testng jar in it, and I had also imported the TestNG through build configuration. That could be why this morning I went back and updated my Mac to Java 1.8.0_92. When I set that to the default environment, the error went away. I did not change anything else. – Tom Apr 25 '16 at 12:57
  • I removed the testNG jar from the original Default JRE Environment, and was able to execute the test case and not receive the Exception in thread "main" error – Tom Apr 25 '16 at 13:05
  • Okay Glad to hear you fixed it! Could you please accept my answer so that others who are having similar problems know that this is credible information? – sebenalern Apr 25 '16 at 14:28