线程“主”中的异常尝试运行TestNG类时,Eclipse中出错 [英] Exception in thread "main" Error in Eclipse when trying to run TestNG class

查看:320
本文介绍了线程“主”中的异常尝试运行TestNG类时,Eclipse中出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用Java 1.7.0_79在Eclipse中运行一个示例TestNG类时,我得到以下错误:

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

我已经尝试通过Eclipse存储安装TestNG,当它没有工作时,我卸载并通过www.beust.com/eclipse站点进行。

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.

我以为是因为我失去了jcommander.jar,所以我甚至走了,跟踪了t帽子下来,并将其包含在我的图书馆。

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.

奇怪的是,我在Windows PC上运行的是相同的配置,并且能够让TestNG脚本运行,但是当我通过相同的设置我的Mac,我得到错误。

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.

这是我要运行的代码:

import org.testng.annotations.Test;

public class NewTest {
  @Test
  public void testMethod() {
      System.out.println("First TestNG test");
  }
}


推荐答案

如果您正在使用没有maven的项目,请确保您将jcommander.jar文件添加到类路径中。确保您的项目结构有一个TestNG库,其中只有一个testng.jar文件。

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.

这篇关于线程“主”中的异常尝试运行TestNG类时,Eclipse中出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆