myeclipse工程   junit不能运行

java.lang.ClassNotFoundException: com.huawei.adapter.XXXXXTest
	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
	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)

 

原因在于maven生成class的目录被改变,需要重新设置output目录,

解决办法一:

打开工程的.classpath文件:

 

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src/main/java"/>
	<classpathentry kind="src" path="src/main/config"/>
	<classpathentry kind="src"  path="src/test/java"/>
                .......
</classpath

  

将output="target/test-classes"加上就好用了

  

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
	<classpathentry kind="src" path="src/main/java"/>
	<classpathentry kind="src" path="src/main/config"/>
	<classpathentry kind="src"  output="target/test-classes" path="src/test/java"/>

  

 解决办法二:

  1.打开项目,右击进入Properties>>JAva Build Path    

  2.勾选下方Allow  output folders for source folders

  3.设置上方的output folder路径

 

posted on 2012-10-19 11:23  NeverGiveUp_ZONE  阅读(13473)  评论(2编辑  收藏  举报