DEV.co
Open-Source Testing · assertj

assertj

AssertJ is a Java testing library that provides fluent, type-specific assertions for unit tests. It allows developers to write readable test conditions using method chaining and IDE code completion, supporting JDK types, Guava, Joda Time, Neo4J, databases, and Swing UI testing.

Source: GitHub — github.com/assertj/assertj
2.8k
GitHub stars
780
Forks
Java
Primary language
Apache-2.0
License (OSI-approved)

Key facts

Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.

FieldValue
Repositoryassertj/assertj
Ownerassertj
Primary languageJava
LicenseApache-2.0 — OSI-approved
Stars2.8k
Forks780
Open issues256
Latest releaseassertj-build-3.27.7 (2026-01-24)
Last updated2026-07-07
Sourcehttps://github.com/assertj/assertj

What assertj is

AssertJ is a modular assertion framework for JVM languages (Java, Kotlin, Groovy) offering strongly-typed assertions with fluent API design. Core module covers JDK collections, strings, streams, and files; additional modules extend support to Guava, temporal types, graph databases, relational databases, and UI frameworks.

Quickstart

Get the assertj source

Clone the repository and explore it locally.

terminalbash
git clone https://github.com/assertj/assertj.gitcd assertj# follow the project's README for install & configuration

Need it deployed, integrated, or customized instead? DEV.co ships production installs.

Best use cases

Unit Testing in Java/Kotlin Projects

Primary use case: writing readable, maintainable assertions in JUnit or TestNG test suites. Type-specific methods reduce boilerplate and improve IDE autocomplete experience.

Data Structure and Collection Validation

Testing Lists, Maps, Sets, and Streams with specialized assertions for containment, ordering, filtering, and transformation validation without manual iteration.

Multi-Module Testing Strategies

Leverage specialized modules (DB, Neo4J, Swing) to unify assertion style across domain-specific testing layers (persistence, graph queries, UI interactions).

Implementation considerations

  • AssertJ requires strong typing; generic wildcards and complex type hierarchies can complicate assertion chains—test IDE autocomplete before wide adoption.
  • Module interdependencies: Guava, Joda Time, and DB modules are separate downloads; ensure Maven/Gradle pulls correct transitive dependencies.
  • Custom assertions can be generated (extension framework exists); factor in learning curve for teams creating domain-specific assertion classes.
  • Performance: fluent API creates intermediate objects; negligible for unit tests, but avoid in tight loops or performance-critical test suites.
  • API surface is large; code reviews should enforce consistent assertion patterns to avoid test code becoming brittle or over-specific.

When to avoid it — and what to weigh

  • Non-JVM Languages — AssertJ is Java/JVM-native. Not suitable for Python, JavaScript, Go, or other language ecosystems; each has idiomatic assertion libraries.
  • Property-Based Testing Requirements — AssertJ is example-based; it lacks built-in property-based testing (generative testing). Consider QuickCheck-style frameworks if that is a core need.
  • Behavioral/BDD-Style Test Narratives — AssertJ focuses on assertions, not full Given-When-Then narrative frameworks. Use Cucumber or Spock if BDD story structure is mandatory.
  • Very Low Java Version Support — If locked to Java 7 or earlier, AssertJ may not be compatible. Check minimum version requirements against your target platform.

License & commercial use

Licensed under Apache License 2.0 (SPDX: Apache-2.0), a permissive OSI-approved license allowing commercial use, modification, and distribution with minimal restrictions (retain license/copyright notices, state changes).

Apache-2.0 permits commercial use without additional licensing fees or restrictions. Can be bundled in proprietary software. Requires retaining license notices in distribution. No warranty or liability guarantees; as-is software.

DEV.co evaluation signals

Editorial assessment — not user reviews. Directional, with an explicit confidence level.

SignalAssessment
MaintenanceActive
DocumentationStrong
License clarityClear
Deployment complexityLow
DEV.co fitStrong
Assessment confidenceHigh
Security considerations

AssertJ is a test library with no network I/O, cryptography, or authentication scope. Security risk surface is minimal. Use standard dependency scanning (Snyk, Dependabot) to monitor for transitive vulnerabilities in rare cases. No secrets or sensitive data should appear in assertion logs.

Alternatives to consider

Hamcrest

Older matcher-based library; less fluent, heavier syntax. Hamcrest is lighter weight but AssertJ's type-specific assertions are more discoverable via IDE.

Truth (Google)

Modern fluent assertion library similar to AssertJ. Smaller ecosystem; fewer domain-specific modules. AssertJ has broader JVM language support and longer adoption track record.

Kotest/Kluent

Kotlin-native assertion DSLs. Ideal if Kotlin is primary language. AssertJ works cross-JVM but KotlinTest syntax is more idiomatic for Kotlin projects.

Software development agency

Build on assertj with DEV.co software developers

Explore AssertJ documentation, check Maven Central for the latest version, and consider whether domain-specific modules (DB, Guava, Neo4J) fit your testing strategy.

Talk to DEV.co

Related open-source tools

Surfaced by semantic similarity across the DEV.co open-source index.

Related on DEV.co

Explore the category and the services that help you build with it.

assertj FAQ

Can I use AssertJ with TestNG or Spock instead of JUnit?
Yes. AssertJ is test-framework agnostic. Works with JUnit, TestNG, Spock, and any framework that runs Java test methods. It provides assertions only, not test runners.
Do I need all modules or just core?
Core covers most needs (JDK types, collections, strings, streams). Add specialized modules (Guava, DB, Swing, Neo4J) only if testing those specific libraries. Keep dependencies minimal.
Is AssertJ thread-safe for concurrent test execution?
Assertions are stateless, so thread-safety is not a concern. AssertJ itself does not manage test state; the test framework and your test code determine concurrency safety.
What is the performance overhead of fluent assertions?
Negligible for unit tests. Fluent chains create temporary objects and method calls; in normal test execution (millisecond scale), this is undetectable. Avoid in performance test tight loops.

Software development & web development with DEV.co

From first prototype to production, DEV.co delivers software development services around tools like assertj. Our software development agency staffs experienced software developers and web developers for custom software development, web development, integrations, and ongoing support across open-source testing and beyond.

Ready to improve your test assertions?

Explore AssertJ documentation, check Maven Central for the latest version, and consider whether domain-specific modules (DB, Guava, Neo4J) fit your testing strategy.