eclipse TestNG 错误:在编译 Maven 项目后在类路径中找不到类
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28673357/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
TestNG ERROR: Cannot find class in classpath after compiling the maven project
提问by Arihant Banthia
I am using maven project and all the testNG tests were working correctly till I compiled and published the project. Now it is giving the error "Cannot find class in classpath"when I execute the tests in eclipse
我正在使用 maven 项目并且所有 testNG 测试都正常工作,直到我编译并发布了该项目。现在,当我在 eclipse 中执行测试时,它给出了错误“在类路径中找不到类”
The test class is in /src/test/java
测试类在 /src/test/java
Below is my sample testng xml:
下面是我的示例 testng xml:
<suite name="Testing1" parallel="false" verbose="10">
<test name="Test1">
<classes>
<class name="com.test.TestClass"/>
</classes>
</test>
</suite>
Can any one tell me why is it not working any more?
谁能告诉我为什么它不再起作用了?
回答by pseudoCoder
Just do Eclipse> Project > Clean and then run the test cases again. It should work.
只需执行 Eclipse> Project > Clean 然后再次运行测试用例。它应该工作。
What it does in background is, that it will call mvn eclipse:clean in your project directory which will delete your .project and .classpath files and you can also do a mvn eclipse:eclipse - this regenerates your .project and .classpath files. Thus adding the desired class in the classpath.
它在后台所做的是,它将在您的项目目录中调用 mvn eclipse:clean ,这将删除您的 .project 和 .classpath 文件,您还可以执行 mvn eclipse:eclipse - 这将重新生成您的 .project 和 .classpath 文件。因此在类路径中添加所需的类。