简体   繁体   English

线程“main”中的异常当尝试运行TestNG类时,Eclipse中出现错误

[英]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: 当我尝试使用Java 1.7.0_79在Eclipse中运行示例TestNG类时,我得到以下错误:

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. 我尝试通过Eclipse商店安装TestNG,但这不起作用。 I uninstalled and did it through the www.beust.com/eclipse site. 我卸载并通过www.beust.com/eclipse网站完成。

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. 我以为是因为我错过了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. 奇怪的是,我在Windows PC上运行相同的配置并且能够运行TestNG脚本,但是当我在Mac上进行相同的设置时,我收到错误。

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. 如果您使用的是没有maven的项目,请确保将jcommander.jar文件添加到类路径中。 Make sure your project structure has a "TestNG" library that has only one testng.jar file inside it. 确保您的项目结构具有“TestNG”库,其中只有一个testng.jar文件。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用ObjectDraw运行Java程序时线程“ main”错误 - Exception in thread “main” error when trying to run a java program with objectdraw 主类在JUnit的线程错误中异常运行 - Main class run with exception in thread error with JUnit 尝试从main方法运行TestNG时,无法在类路径中找到类 - Cannot find class in classpath when trying to run TestNG from the main method “主要方法不公开”-尝试在Eclipse上运行程序时出现错误消息 - “Main Method not Public” - Error message when trying to run program on Eclipse 在Eclipse中运行TestNG脚本的“找不到主类”错误 - “Could not find main class” error running TestNG script in Eclipse 我在线程“main”org.testng.TestNGException 中收到错误异常:运行测试时无法从文件加载 class - I am getting error Exception in thread "main" org.testng.TestNGException: Cannot load class from file while running a test 尝试运行ST312_TestMain类时,线程“ main”中的异常java.lang.ExceptionInInitializerError - Exception in thread “main” java.lang.ExceptionInInitializerError while trying to run ST312_TestMain class 尝试使用 Java 在 Selenium 中运行测试用例时,线程“主”java.lang.NullPointerException 出现异常 - Exception in thread "main" java.lang.NullPointerException when trying to run a test case in Selenium with Java eclipse时出错:线程“ main”中的异常java.lang.Error - eror when get eclipse : Exception in thread “main” java.lang.Error NACHOS关于线程“ main”中的eclipse异常 - NACHOS on eclipse exception in thread “main”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM