Unit Test Patterns: The Domain Test Values Class

On my latest Java project, my colleagues and I are keen to improve the readability of test classes. We’ve chosen to use Mockito and Hamcrest because of their natural language approach to mocking and assertions, but on their own they can’t always convey the meaning of values used in a test.

To overcome this, we use a pattern which I’ll call the “Domain Test Values Class”,  the purpose of which is to provide values used in the testing of a domain in a way which improves understanding of test code by increasing readability and adding meaning to values.

Continue reading