Re: New assertEquals() for Beans
| Newsgroups | gmane.comp.java.junit.user |
|---|---|
| Message-ID | <CAKi4273P53mWQOEFmvsSJGz6CWbkrLwdAB8TC=oe8TCWO-us5A@mail.gmail.com> |
Having faced a similar problem in the past we created a Hamcrest matcher to do deep object comparisons for us. Internally it serializes to json to do the actual comparison. You can read why we wrote it and how to use it here: http://tech.shazam.com/server/easing-matcher-creation-with-shazamcrest/ Or get it from github here: https://github.com/shazam/shazamcrest One of the real benefits of using Json is that running tests in your IDE can make use of the "click to see difference" feature to get an easy to read view of what was different. On Wed, May 14, 2014 at 5:52 PM, [email protected] [junit] < [email protected]> wrote: > > > Hi JUnit-Folks! > > > We would like to contribute to JUnit by adding a new assertEquals()-method > that compares classes that satisfy the JavaBeans specification. The method > could create a detailed errormessage to show which properties of the > compared beans don't match if the comparison fails. > > > The idea was born, since we have offen faced a situation where we compared > two Beans with several properties using the assertEquals(Object, > Object)-method. If that assert fails you don't know which properties of the > compared Beans don't match and cause the assert to fail. > > Currently you often end up with tedious extra work to find out which > property is wrong, like > > > - writing assertEquals() for every single property, > - debugging the testcase, > - or writing a toString()-method that prints out the property-values, > so that the values are visible in the fail-message and can be compared > manually. > > > Since we believe that this situation is quite common and independent from > special architectures, libraries or projects we would appreciate a > junit-internal solution. > > > What do you think about adding such an assertEqualsBean()-method to > Assert? We would be glad to create a pull-request if you like the idea! > > > Greetings > > Maurice-Marie Stromer, > > Jan Schankin > > > > -- Maybe she awoke to see the roommate's boyfriend swinging from the chandelier wearing a boar's head. Something which you, I, and everyone else would call "Tuesday", of course.