最近在使用JUnit做单元测试时,发现新写好的测试类运行总是出错,报找不到类异常。



JUnit报错:java.lang.ClassNotFoundException: com.mogodb.test.test_java



Class not found com.mogodb.test.test
java.lang.ClassNotFoundException: com.mogodb.test.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:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
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)



JUnit报错:java.lang.ClassNotFoundException: com.mogodb.test.test_java



  查找对应的classes文件夹确实乜有发现响应的class文件生成。

  查看项目确实选择了自动编译!

  上网查找资料,发现了如下的解决办法:

  只要把Java--------compiler-------building-------Buil path problems ------- incomplete build path 和 Circular dependencies改成warning就可以了。

JUnit报错:java.lang.ClassNotFoundException: com.mogodb.test.test_开发工具_03

 

JUnit报错:java.lang.ClassNotFoundException: com.mogodb.test.test_eclipse_04