AssertJ
Learn about the AssetJ library, and how it helps us to write better unit tests.
AssertJ is a Java library used alongside JUnit 5 to write fluent assertions.
AssertJ contains feature-rich assertions and helpful error messages. This improves test code readability, and helps us debug failed unit tests.
Different modules of AssertJ
AssertJ is composed of several modules:
-
Core Module - This module provides assertions for JDK types (String, Iterable, Stream, Path, File, Map, etc.)
-
Guava: Provides assertions for types coming from the “Guava” library (Multimap, Optional, etc.).
-
Joda Time: This module provides assertions for Joda Time Types (DateTime, LocalDateTime).
-
Neo4J: Provides assertions for Neo4J types (Path, Node, Relationship).
-
DB: Provides assertions for relational database types (Table, Row, Column).
-
Swing: Provides an API for functional testing of Swing user interfaces.
Set up AssertJ using Maven
We use the following Maven coordinates to install the AssertJ library with Maven.
Get hands-on with 1400+ tech skills courses.