aspose file tools*
The moose likes Testing and the fly likes getting started with jmock Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "getting started with jmock" Watch "getting started with jmock" New topic
Author

getting started with jmock

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
Hi,
my name is sura. I doing the 'getting start' of jmock and here is the URL
http://www.jmock.org/getting-started.html

when I run junit it failed.
let me show you what I did and perhaps you can tell me what I did wrong.
I have a package where i put all my classes and interface.
the package name is com.oxman.test
in com.oxman.test I have two classes and an interface which are
Subscriber (an interface)
Publisher(a class) and my test class
PublisherTest

and here is the code for each class

Subscriber


Publisher



PublisherTest


when I run the unit testing, here is the error stack
java.lang.NoClassDefFoundError: org/hamcrest/TypeSafeMatcher
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
at org.jmock.internal.InvocationExpectationBuilder.createExpectationFrom(InvocationExpectationBuilder.java:77)
at org.jmock.Mockery.dispatch(Mockery.java:196)
at org.jmock.Mockery.access$000(Mockery.java:37)
at org.jmock.Mockery$MockObject.invoke(Mockery.java:246)
at org.jmock.internal.InvocationDiverter.invoke(InvocationDiverter.java:27)
at org.jmock.internal.ProxiedObjectIdentity.invoke(ProxiedObjectIdentity.java:36)
at org.jmock.lib.JavaReflectionImposteriser$1.invoke(JavaReflectionImposteriser.java:33)
at $Proxy0.receive(Unknown Source)
at com.oxman.test.PublisherTest$1.<init>(PublisherTest.java:28)
at com.oxman.test.PublisherTest.testOneSubscriberReceivesAMessage(PublisherTest.java:25)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at junit.framework.TestCase.runTest(TestCase.java:168)
at junit.framework.TestCase.runBare(TestCase.java:134)
at junit.framework.TestResult$1.protect(TestResult.java:110)
at junit.framework.TestResult.runProtected(TestResult.java:128)
at junit.framework.TestResult.run(TestResult.java:113)
at junit.framework.TestCase.run(TestCase.java:124)
at junit.framework.TestSuite.runTest(TestSuite.java:232)
at junit.framework.TestSuite.run(TestSuite.java:227)
at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:81)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:38)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:460)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)


from what it said is that
this line

in PublisherTest causes a java.lang.NoClassDefFoundError: org/hamcrest/TypeSafeMatcher exception

so if anyone has any idea what went wrong please enlighten me.
that will very much be appreciated.

Thank you so much

Sura
sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
problem solved
my colleague told me to add a harmcrest library and it worked!

Sura
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: getting started with jmock