为什么我的测试没有运行 [英] Why is my test not running

查看:86
本文介绍了为什么我的测试没有运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最奇怪的事情发生了,我的测试运行正常,现在它不再是我没有更改代码这里是例外:

Strangest thing happened my test was running ok and now its not anymore I didn't change the code at all here is the exception :

Class not found com.example.test
java.lang.ClassNotFoundException: com.example.test
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:693)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:429)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:452)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)


推荐答案

我看到你正在使用Eclipse,但你是否也使用其他外部构建/测试工具,如Ant或Maven?有时Eclipse也会在使用其他外部工具时失去同步。

I see that you are using Eclipse, but are you also using some other external build/test tool like Ant or Maven? Sometimes Eclipse can get out of sync when also using other external tools.

如果您使用外部工具,请执行清理生成的工件所需的任何操作(例如,mvn clean)。然后刷新Eclipse项目并按照之前的建议进行干净的构建。然后尝试使用Eclipse再次运行单元测试。

If you are using external tools, do whatever is necessary to clean up generated artifacts (e.g. mvn clean). Then refresh the Eclipse project and do a clean build as suggested previously. Then try running your unit test again using Eclipse.

祝你好运,希望这会有所帮助。

Good luck and hope this helps.

这篇关于为什么我的测试没有运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆