• 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
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Problem Using EasyMock.expect for Object references

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am using EasyMock 2.2. I have a function like ...

void updateCustDetails (Customer cust ) {}


When using EasyMock.expect , I am using the following code

EasyMock.expect(dataServiceMock.updateCustDetails(cust));

This always gives an assertion error because, 'cust' is a reference type and the assertion is comparing the memory locations and therefore failing each time. During testing the Object sent has the same values for attribute but as it is a different object it has a different memory location.

Which is the best way to get past this problem ? Thanks.

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The default matcher used by EasyMock is eq(). It calls equals. If this doesn't work for you, you need to use your own matcher. One easy way is to make a comparator suiting your needs and give it to the cmpEq(Comparable<T>) matcher.
 
Mo-om! You're embarassing me! Can you just read a tiny ad like a normal person?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic