• 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

EqualsTester - gsbase

 
Ranch Hand
Posts: 254
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had a look at the EqualsTester API from
http://gsbase.sourceforge.net/apidocs/com/gargoylesoftware/base/testing/EqualsTester.html

I am still not able to understand the need of EqualsTester, what advantage does it have over normal assertEquals method ?

EqualsTester ensures that the equals() and hashCode() methods have been implemented correctly.
Above is given in the API, may be there is some hint here, which I am not able to figure out because in case of assertEquals too it first checks the hashcode and then the equals method, right?

Regards,
Joshua
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The two have totally different intentions.

The EqualsTester sets out to test whether equals and hashcode follow the contracts of those methods, as defined by the API doc.

The assertEquals method asserts that two objects are equal, *assuming that equals is already implemented correctly*. It doesn't make any use of the hashcode method.
reply
    Bookmark Topic Watch Topic
  • New Topic