File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Engineering » Testing
Bookmark "getting started with jmock" Watch "getting started with jmock" New topic

getting started with jmock

sura watthana
Ranch Hand

Joined: Sep 13, 2004
Posts: 77
my name is sura. I doing the 'getting start' of jmock and here is the URL

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

and here is the code for each class




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 Source)
at Source)
at$100(Unknown Source)
at$ Source)
at Method)
at 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(
at org.jmock.Mockery.dispatch(
at org.jmock.Mockery.access$000(
at org.jmock.Mockery$MockObject.invoke(
at org.jmock.internal.InvocationDiverter.invoke(
at org.jmock.internal.ProxiedObjectIdentity.invoke(
at org.jmock.lib.JavaReflectionImposteriser$1.invoke(
at $Proxy0.receive(Unknown Source)
at com.oxman.test.PublisherTest$1.<init>(
at com.oxman.test.PublisherTest.testOneSubscriberReceivesAMessage(
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(
at junit.framework.TestCase.runBare(
at junit.framework.TestResult$1.protect(
at junit.framework.TestResult.runProtected(
at junit.framework.TestSuite.runTest(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(

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 watthana
Ranch Hand

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

I agree. Here's the link:
subject: getting started with jmock
It's not a secret anymore!