Eloquent JUnit: from Matchers to Builders (EN)


  1. Context
  2. The Test: verbose
  3. The Matcher: concise
  4. The Builder: eloquent
  5. Improvements
  6. Conclusion
  7. Sources


I had to make an evolution on a legacy code handling a large number of nested Java objects. The code was instancing several thousands of the class Demande (“Request”) from a ResultSet.

This class Demande was characterized by:

  • plenty of attributs, like dates or amounts,
  • and a lot of nested objects. Under the root Demande, there were 9 sub-levels with as much of 20 attributes each.

So, I began to write tests to guarantee non-regression…

Lire la suite