Skip to content
AssertJ is a library providing easy to use rich typed assertions
Java Shell
Branch: master
Clone or download
Latest commit 6513f6e Jan 20, 2020
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Setup GitHub actions for windows and macos. Dec 13, 2019
.mvn/wrapper [mvn] Bump maven wrapper to 0.5.6 (#1736) Dec 27, 2019
src Fix typos Jan 20, 2020
.editorconfig Implementation of isCloseToUtcNow Jun 24, 2019
.gitignore Update maven wrapper to 0.5.3 (#1482) Apr 3, 2019
.travis.yml
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md (#1029) Jul 9, 2017
CONTRIBUTING.md Add combined WHEN/THEN example to contribution guidelines (#1707) Nov 22, 2019
ISSUE_TEMPLATE.md Update ISSUE_TEMPLATE.md as we don't support 2.x actively anymore Jan 5, 2018
LICENSE.txt Upgrade parent to version 2.2.6 and Mockito to version 3.0.0 (#1589) Sep 9, 2019
PULL_REQUEST_TEMPLATE.md Update contributor's guide Sep 22, 2019
README.md Add Github action CI status Dec 15, 2019
mvnw [mvn] Bump maven wrapper to 0.5.6 (#1736) Dec 27, 2019
mvnw.cmd [mvn] Bump maven wrapper to 0.5.6 (#1736) Dec 27, 2019
pom.xml Bump junit-jupiter from 5.5.2 to 5.6.0 Jan 20, 2020
verify.bndrun use bnd 4.3.0 to a) use -noclassforname instruction b) generate most … Nov 3, 2019

README.md

AssertJ - Fluent assertions for java

Travis build Status (master) Github CI status Maven Central Javadocs Quality Gate Status

AssertJ provides a rich and intuitive set of strongly-typed assertions to use for unit testing (with JUnit, TestNG or any other test framework).

The new AssertJ web site contains the AssertJ Core documentation.

You can ask questions in stackoverflow (assertj tag) and make suggestions by simply creating an issue.

AssertJ's goals

AssertJ's ambition is to provide a rich and intuitive set of strongly-typed assertions for unit testing.

The idea is that disposal assertions should be specific to the type of the objects we are checking when writing unit tests. If you're checking the value of a String, you use String-specific assertions. Checking the value of a Map? Use Map-specific assertions to easily check the contents of the map.

AssertJ is composed of several modules:

Assertion missing? Please create an issue!

AssertJ's assertions are super easy to use: just type assertThat followed by the actual value in parentheses and a dot, then any Java IDE will show you all assertions available for the type of the object. No more confusion about the order of "expected" and "actual" value.

AssertJ's assertions are very close to plain English.

A lot of effort has been spent to provide intuitive failure messages showing clearly why the assertion failed.

Note that AssertJ 3.x requires at least Java 8 and AssertJ 2.x requires at least Java 7.

Quickstart

It is easy to start using AssertJ, just follow the one minute starting guide.

Latest News

To read details on the latest releases, please go to AssertJ Core latest news.

Assertions for custom types

Having assertions for common types like List is great, but you might want some assertions specific to your own types. It is simple to write assertions for your custom types with AssertJ because it is easily extensible.

Moreover, to ease your work, we provide assertions generator that can take a set of custom types and create specific assertions. The tools provided are:

Replacing JUnit assertions with AssertJ Assertions

To help you replace JUnit assertions with AssertJ ones, you can use a script or do regexp search and replace manually as described here.

Want to contribute?

You are encouraged to contribute any missing, useful assertions. To do so, please read the contributing section.

You can’t perform that action at this time.