【问题标题】:Error: Could not find or load main class org.testng.TestNG错误:无法找到或加载主类 org.testng.TestNG
【发布时间】:2017-11-03 05:56:09
【问题描述】:

错误:无法找到或加载主类 org.testng.TestNG

我使用以下步骤/命令通过命令提示符运行我的 testNG 脚本:

1. in my project folder, create a lib folder and copy all the jar files
2. open cmd --> cd myProjectDirectoryPath
3. set classpath=myProjectDirectoryPath/bin
4. set classpath=myProjectDirectoryPath/lib/*
5. java org.testNG.TestNG testng.xml

但在那之后我得到了无法找到或加载主类 org.testng.TestNG 错误。尝试调试但仍不成功。谁能帮帮我。

【问题讨论】:

    标签: jenkins selenium-webdriver testng


    【解决方案1】:

    至少尝试添加到classpath

    set classpath=myProjectDirectoryPath/bin
    set classpath=%classpath%;myProjectDirectoryPath/lib/*
    

    如果不是,则第二个“set”覆盖第一个。

    在java命令中直接指定cp(classpath):

    java -cp myProjectDirectoryPath/bin;myProjectDirectoryPath/lib/* org.testng.TestNG testng.xml
    

    在这两种情况下,请确保您在其中一个文件夹中有 testng.jar

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-05-11
      • 2020-12-23
      • 2016-06-12
      • 2016-03-16
      • 2016-01-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多