truth
Truth is a Java assertion library that makes test code more readable and failure messages clearer. Maintained by the Guava team and used extensively in Google's own tests, it provides fluent syntax for assertions on JDK and third-party types.
Key facts
Objective fields from the source. Values we can't verify are shown as “Unknown” rather than guessed.
| Field | Value |
|---|---|
| Repository | google/truth |
| Owner | |
| Primary language | Java |
| License | Apache-2.0 — OSI-approved |
| Stars | 2.8k |
| Forks | 269 |
| Open issues | 76 |
| Latest release | v1.4.5 (2025-09-10) |
| Last updated | 2026-07-06 |
| Source | https://github.com/google/truth |
What truth is
Truth is an Apache 2.0 licensed assertion framework for Java/Android with native support for JDK and Guava types, extensible subject types, and fluent assertion chains. It provides custom failure message formatting to improve test debuggability and is maintained as part of the Guava project.
Get the truth source
Clone the repository and explore it locally.
git clone https://github.com/google/truth.gitcd truth# follow the project's README for install & configurationNeed it deployed, integrated, or customized instead? DEV.co ships production installs.
Best use cases
Implementation considerations
- Add com.google.truth:truth dependency to Maven/Gradle build; import Truth static methods (assertThat, assertWithMessage) and integrate into existing test classes.
- Truth integrates with JUnit via standard Java test runners; no special configuration required for basic usage.
- Extensibility requires implementing Subject and SubjectFactory for custom types; document custom assertion APIs clearly for team adoption.
- Fluent syntax changes assertion call patterns; plan for incremental migration of existing JUnit assertion code if moving from basic assertEquals style.
- Truth's failure messages are automatically rich; no need for custom error handling, but leverage custom subjects to provide context-aware messages for domain objects.
When to avoid it — and what to weigh
- Not using Java/JVM languages — Truth is Java-specific. Non-JVM projects need alternative assertion libraries.
- Requiring heavy assertion library ecosystem features — For advanced mocking, stubbing, or behavior-driven development (BDD) syntax, consider frameworks that bundle these capabilities (e.g., JUnit + Mockito or Spock).
- Minimal test framework footprint required — Truth adds a runtime dependency. Projects with strict dependency minimization policies may prefer JUnit's built-in assertions or alternative minimal assertion libraries.
- Android projects with strict method count constraints — While Truth supports Android, method count overhead may be a concern in heavily constrained builds. Verify impact in your target configuration.
License & commercial use
Apache License 2.0 (Apache-2.0): Permissive OSI license. Grants rights to use, modify, and distribute. Includes liability disclaimer and trademark protection clause. Requires license and copyright notice preservation.
Apache 2.0 is a permissive license that explicitly permits commercial use, including closed-source applications. No commercial restrictions or proprietary licensing model applies. Redistribution requires license notice inclusion.
DEV.co evaluation signals
Editorial assessment — not user reviews. Directional, with an explicit confidence level.
| Signal | Assessment |
|---|---|
| Maintenance | Active |
| Documentation | Strong |
| License clarity | Clear |
| Deployment complexity | Low |
| DEV.co fit | Good |
| Assessment confidence | High |
Truth is a test-time library with no network, file I/O, or privileged operations. Security surface is limited to test code paths. No known CVEs or security advisories referenced in provided data. Assess for code injection risks only if custom subjects process untrusted test inputs (uncommon).
Alternatives to consider
AssertJ
Similar fluent assertion library with broader third-party type support and more active community plugins. Consider if needing less Google-centric ecosystem integration.
JUnit 5 Assertions (org.junit.jupiter.api.Assertions)
Hamcrest Matchers
Older, matcher-based assertion library. More verbose syntax but very stable; consider only if already embedded in legacy test suite.
Build on truth with DEV.co software developers
Truth improves test readability and failure diagnostics with fluent assertions. Review the extension API and integration path with your JVM stack. Contact us to assess fit with your testing strategy and custom assertion needs.
Talk to DEV.coRelated on DEV.co
Explore the category and the services that help you build with it.
truth FAQ
Can Truth be used with existing JUnit tests?
What is the performance impact of Truth compared to plain JUnit assertions?
Is Truth suitable for Android testing?
How do I write custom assertions for my domain objects?
Custom software development services
DEV.co helps companies turn open-source tools like truth into production software. Our software development services cover the full lifecycle — architecture, web development, integration, and maintenance — delivered by software developers and web developers who ship. Engage our software development agency to implement or customize it for your open-source testing stack.
Evaluate Truth for Your Java Test Suite
Truth improves test readability and failure diagnostics with fluent assertions. Review the extension API and integration path with your JVM stack. Contact us to assess fit with your testing strategy and custom assertion needs.