Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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");
  }
}
like image 507
Tom Avatar asked Feb 17 '26 22:02

Tom


1 Answers

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.

like image 123
sebenalern Avatar answered Feb 19 '26 10:02

sebenalern



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!