CheckOps home

Tools directory

A

CheckOps

AssertJ

AssertJ is an Apache-2.0 fluent assertions library for Java, with rich, discoverable assertions for core types, collections, exceptions, dates and more, plus soft assertions and custom assertion generation.

Visit website

Latest public signals

Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.

Visit Website

Introduction

AssertJ provides fluent assertions for Java. You start with assertThat(actual) and your IDE’s code completion shows only the assertions that make sense for that type, so tests read like sentences: assertThat(names).hasSize(3).contains("Ana").doesNotContain("Bob"). Clear failure messages show both the expected and actual values, which speeds up debugging compared with plain JUnit assertions.

The core module covers strings, numbers, collections, maps, optionals, streams, files, dates and times, and exceptions (assertThatThrownBy(...), assertThatExceptionOfType(...)). Collection assertions can extract properties (extracting("name")), filter and compare element by element, and recursive comparison (usingRecursiveComparison()) compares object graphs field by field with configurable ignores. Soft assertions collect all failures in a test instead of stopping at the first. Additional modules cover Guava and database assertions, and an assertions generator creates domain-specific assertions for your own classes. AssertJ works with JUnit 4, JUnit 5 and TestNG; the latest build release at the time of writing was 3.27.7, published on 24 January 2026.

The source code is at assertj/assertj on GitHub under the Apache-2.0 licence, with about 2,900 stars; the most recent commit was on 10 November 2026.

Features

  1. Fluent, type-specific API: Code completion surfaces relevant assertions.
  2. Recursive comparison: Compare object graphs field by field.
  3. Soft assertions: Report every failure in one run.
  4. Exception assertions: Expressive checks for thrown exceptions and messages.

Pros

  1. Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
  2. Actively maintained: The repository had commits as recent as 10 November 2026.

Cons

  1. Another dependency: JUnit’s built-in assertions may suffice for simple projects.
  2. Large API: Many options can lead to inconsistent styles across a team.
<dependency>
  <groupId>org.assertj</groupId>
  <artifactId>assertj-core</artifactId>
  <version><!-- latest --></version>
  <scope>test</scope>
</dependency>
import static org.assertj.core.api.Assertions.*;

@Test
void ordersAreSortedAndValid() {
    List<Order> orders = service.findRecent();
    assertThat(orders)
        .hasSize(3)
        .extracting(Order::status)
        .containsOnly(Status.PAID);
    assertThatThrownBy(() -> service.cancel(-1))
        .isInstanceOf(IllegalArgumentException.class)
        .hasMessageContaining("id");
}

Resources:

Pricing

AssertJ is free and open source under the Apache-2.0 licence.

  1. Java teams using JUnit or TestNG who want readable assertions and better failure messages.
  2. Codebases with complex domain objects, using recursive comparison.

Conclusion

AssertJ is the de facto fluent assertions library for Java, improving test readability and diagnostics with minimal effort.

Alternatives

Other tools on CheckOps that cover similar ground. Open a page, or compare one with AssertJ side by side.