java.lang.NoClassDefFoundError: org/hamcrest/SelfDescribing in Intellij

前端 未结 4 1061
难免孤独
难免孤独 2021-01-17 07:12

I used Intellij Idea 12 Community edition. I am trying to create test case for my class by creating test case. When i run my test case it says

java.lang.NoC         


        
相关标签:
4条回答
  • 2021-01-17 07:50

    Did you include the hamcrest-core-1.3.jar file in your classpath? If not included means include that jar and try once again.

    0 讨论(0)
  • 2021-01-17 07:53

    add junit.jar to your project dependence. you may also need to add hamcrest.jar in addition.

    Open File->Project Structure,Click Modules->Dependences,add junit.jar.

    0 讨论(0)
  • 2021-01-17 07:57

    If you come across this (and a few other threads) on this error and adding the jar to dependencies doesn't work, you will need to add to the general java classpath.

    I encountered this error in OSX where maven would download the dependency, but not find it when in fork mode.

    Adding all the hamcrest jars to Library/Java/Extensions finally fixed the problem when nothing else would.

    0 讨论(0)
  • 2021-01-17 07:58

    Latest version of hamcrest-all is available at: https://search.maven.org/search?q=a:hamcrest-all

    Download this version (as opposed to the hamcrest-core) and that should do it.

    0 讨论(0)
提交回复
热议问题