错误:无法找到或加载主类 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/