• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Object argument does not work in method call on mock object

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to mock DAO objects used in a Spring application. I can easily create mock or stub objects and inject them into my service. However, in all cases an object is passed in as an argument and an object is returned as an argument on the method calls in the mock object. I was trying to find a mocking framework that handles this situation. Here is my code with EasyMock. The problem is the Unit object passed to the method on the mock object is created in the service and can not be passed in. When easymock does the compare for the expect, its comparing two different Unit objects with the same values which results in not equal and a failure.




I also tried to handle this in Groovy, which didn't work. I know I can create my own Mock objects for each DAO to handle this. It just seems like a mocking framework should handle this scenario, so I don't have to create the objects. Any ideas on how I should handle this.


Thanks,
Jeff

 
author & internet detective
Posts: 41878
909
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Easymock lets you create a custom matcher rather than using the standard == check. That way you can look at values instead of identity.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic