0

I have an entity in my domain named Order. It has properties such as dateOfOrder, status, orderItems etc.

In my tests I need to be sure that all properties have been set. Currently I write a lot of asserts to be sure that all properties have been set.

assertEqual(4, order.getId());
...

However I would like to create my own assertion for an order (and other kinds of domain objects) like this:

assertEqual(myExpectedOrder, order);

I have been looking at writing custom matchers etc. But I don't know if they are the right thing to use. I don't want the custom assertion in a method, I want to have separate assertion classes such as OrderAssert or OrderMatcher - whatever is the correct thing to use.

What should I use and how? I want to check that all the attributes contain the expected values.

LuckyLuke
  • 47,771
  • 85
  • 270
  • 434
  • 1
    Overriding equals is not an option? – Michal Gruca Sep 14 '14 at 21:16
  • possible duplicate of [Is there a simple way to match a field using Hamcrest?](http://stackoverflow.com/questions/5033526/is-there-a-simple-way-to-match-a-field-using-hamcrest) – Joe Jan 01 '15 at 06:32

0 Answers0