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.