• Reusable Test Data with Object Mother and Builder Pattern in Java

    From my observation, code bases with a high test coverage and a certain level of complexity tend to have cluttered and messy tests. Such tests are often dominated by the preparation step in order to prepare test data or bring the system into a state required for the test. The actual test code, such as invocation of the component-under-test and verification of the results, can easily be buried under the preparation step. To ease such problems and to improve readability and maintainability of test code in general, I like to combine the Builder pattern with the Object Mother pattern and randomized test data.