No Such Method Error when creating JUnit test

烈酒焚心 提交于 2019-11-30 08:55:16

The java.lang.NoSuchMethodError always indicates that the version of a class that was on your compiler's classpath is different from the version of the class that is on your runtime classpath (had the method been missing at compile-time, the compile would have failed.)

In this case, you had a different version of org.objectweb.asm.ClassWriter on your classpath at compile time than is on your runtime classpath.

Definitely you have different versions of your ClassWriter class at runtime than compile time.

I think you are picking up an incorrect version of asm.jar somewhere in the classpath you are using for your tests.

I had a similar error using Spring 2.5 with Hibernate on NetBeans 6.5. One way I resolved the issue was downloading Spring 3.0 M2 and creating a NetBeans library I called Spring_3 using the jars from the distro. This library also had to include the antlr-runtime-3.0.jar.

See: http://forum.springsource.org/showthread.php?t=65324

-Leo

I would like to share my suggestion for anyone who comes across this JUnit Testing for Android; none of the above worked for me and this was a simple fix:

In Eclipse>>project properties>>Android>> make sure that the project you are testing is referenced under Library. 'is library' can remain unchecked

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!