Deal of the Day

Home » Main » Manning Forums » 2005 » POJOs in Action

Thread: jMock fails

Reply to this Thread Reply to this Thread Search Forum Search Forum Back to Thread List Back to Thread List

Permlink Replies: 2 - Pages: 1 - Last Post: Sep 27, 2009 6:23 PM by: simbo1905
davidxl

Posts: 1
From: Chicago
Registered: 3/6/08
jMock fails
Posted: Mar 6, 2008 1:25 PM
  Click to reply to this thread Reply

Hi,

I ran the jMock tests for Chapter 3 , and all of them failed for me.

I'm using RAD 7, Java 5, and jMock 1.2.

When I tested PlaceOrderServiceTests.java as a JUnit, I got java.lang.IllegalArgumentException: net.chrisrichardson.foodToGo.domain.PendingOrder is not an interface. That was from the line:

mockPendingOrder = new Mock(PendingOrder.class);

Could anyone tell me what I should do to be able to run the tests?


Many thanks,
David

SomeGuy

Posts: 1
Registered: 8/28/08
Re: jMock fails
Posted: Aug 28, 2008 9:05 PM   in response to: davidxl in response to: davidxl
  Click to reply to this thread Reply

You need to import org.jmock.cglib.MockObjectTestCase instead of the MockObjectTestCase from something like org.jmock.MockObjectTestCase if you want to mock a class rather than an interface. Note that this is for jmock 1.x only.

simbo1905

Posts: 30
From: London
Registered: 6/13/06
Re: jMock fails
Posted: Sep 27, 2009 6:23 PM   in response to: davidxl in response to: davidxl
  Click to reply to this thread Reply

RAD is based on Eclipse but sometime (mostly!) makes things harder when not working directly with websphere. Although some companies force the use of a given IDE in order to see things working it is a good idea to run things on a vanilla eclipse running maven which lets you see library versions are being used to help you debug things in a corporate IDE. Here is a link to a post which shows the steps to get things running in eclipse:

http://www.manning-sandbox.com/thread.jspa?messageID=92022#92022

Legend
Gold: 300 + pts
Silver: 100 - 299 pts
Bronze: 25 - 99 pts
Manning Author
Manning Staff