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.
Latest public signals
Not refreshed yet. Refresh reads the public site and, when the entry has a GitHub repository, the latest release.
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
- Fluent, type-specific API: Code completion surfaces relevant assertions.
- Recursive comparison: Compare object graphs field by field.
- Soft assertions: Report every failure in one run.
- Exception assertions: Expressive checks for thrown exceptions and messages.
Pros
- Free to use: Open source under the Apache-2.0 licence, so the core tool costs nothing to use.
- Actively maintained: The repository had commits as recent as 10 November 2026.
Cons
- Another dependency: JUnit’s built-in assertions may suffice for simple projects.
- Large API: Many options can lead to inconsistent styles across a team.
Usage and Links (Example)
<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.
Recommended for?
- Java teams using JUnit or TestNG who want readable assertions and better failure messages.
- 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.
JJUnit 5JUnit 5 is the current JUnit for Java and the JVM: Jupiter for new tests, Platform to launch them, Vintage to run JUnit 4.Compare with AssertJ
TTestNGTestNG is an Apache-2.0 testing framework for Java, inspired by JUnit and NUnit, with annotations, groups, dependencies, data providers, parallel execution and XML suite configuration; it requires Java 11+.Compare with AssertJ
MMockitoMockito is the MIT-licensed, most popular mocking framework for Java, used to create mocks, stubs and spies with a clean API; Mockito 5 uses the inline mock maker by default and requires Java 11.Compare with AssertJ
SSpock FrameworkSpock is an Apache-2.0 BDD-style testing and specification framework for Java and Groovy applications, with given/when/then blocks, powerful data-driven tests and built-in mocking, running on the JUnit Platform.Compare with AssertJ
KKotestKotest is an Apache-2.0 Kotlin multiplatform test framework with multiple testing styles, a large assertions library and built-in property-based testing.Compare with AssertJ
AArchUnitArchUnit is an Apache-2.0 Java library for checking architecture rules (layers, dependencies, cycles, naming) as ordinary unit tests with any plain Java unit testing framework.Compare with AssertJ