Have fun learning about Test-Driven Development with JitterTed's TDD Game

AssertJ


Cheat Sheet

This is a draft of a “cheat sheet” for AssertJ, a fluent assertions library for use with Java and JUnit.

What’s in the Cheat Sheet?

Asserting that the contents of a List, Set, and other Iterables, is where AssertJ’s contains methods come in really handy. I often get confused with variations of contains, such as containsOnly and containsExactly, so I created some examples of tests using these variations:

  1. contains
  2. containsOnly
  3. containsOnlyOnce
  4. containsExactly
  5. containsExactlyInAnyOrder

Eventually the cheat sheet will cover more of the methods that I commonly use in my tests. If you want to stay updated, subscribe to my email list at the bottom of this page. If you have suggestions for which assertions of AssertJ to add, join my Discord, email me (ted@ this domain) or message me on Twitter or Mastodon.

Download the Cheat Sheet

Click here for the PDF of the cheat sheet.


Make Your Code More Testable™️

Don't miss out on ways to make your code more testable. Hear about new Refactoring techniques, improving the Test-Driven Development process, Hexagonal Architecture, and much more.

    We respect your privacy. Unsubscribe at any time.