jenkins - 错误 : Could not find or load main class org. testng.TestNG

标签 jenkins selenium-webdriver testng

错误:无法找到或加载主类 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 错误。尝试调试但仍然没有成功。有人可以帮助我吗。

最佳答案

至少尝试添加到 classpath:

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

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

在 java 命令中直接指定 cp(类路径):

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

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

关于jenkins - 错误 : Could not find or load main class org. testng.TestNG,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44318463/

相关文章:

jenkins - 通过 jenkins 将应用部署到 kubernetes

java - Selenium Webdriver - 单击多个下拉菜单时出现陈旧元素异常,而 HTML DOM 没有更改

java - 远程主机上的 Selenium 2.0 机器人类

java - Spring bean 创建但未 Autowiring

Jenkins 多分支管道不尊重 Jenkinsfile 中的静默期

jenkins - 如何修复 Jenkins java.lang.IllegalStateException : An attempt to save the global configuration was made before it was loaded

html - 转换为 CSS 选择器

java - 如何使用 Java 检查 Selenium WebDriver 中的元素是否可点击

java - 如何替换数据提供者的硬编码值

.net - Jenkins、MSBuild 和 Web 部署 : Unable to create Web Package