Supported type assertions

AssertJ provides assertions specific to the object under test type, the following sections list the supported types grouped by categories.

The provided assertions for each of these types are documented later on.

Common types

BigDecimal

BigInteger

CharSequence

Class

Date

File

Future / CompletableFuture

InputStream

Iterable (including any kind of Collection)

Iterator

List

Map

Object

Object[] and Object[][]

  • Optional

  • OptionalInt / OptionalLong / OptionalDouble

Path

Predicate

Stream

String

Throwable / Exception

URL and URI

Primitive types

Primitive types and their wrapper:

  • short / Short

  • int / Integer

  • long / Long

  • byte / Byte

  • char / Character

  • float / Float

  • double / Double

Primitive type arrays:

  • short[]

  • int[]

  • long[]

  • byte[]

  • char[]

  • float[]

  • double[]

Primitive type 2D arrays:

  • short[][]

  • int[][]

  • long[][]

  • byte[][]

  • char[][]

  • float[][]

  • double[][]

Java 8 Temporal types

Instant

LocalDate

LocalDateTime

LocalTime

OffsetDateTime

OffsetTime

ZonedDateTime

Period

Atomic types

Atomic basic types:

  • AtomicInteger

  • AtomicLong

  • AtomicBoolean

Atomic array types:

  • AtomicIntegerArray

  • AtomicLongArray

Atomic reference types:

  • AtomicMarkableReference

  • AtomicStampedReferenceAssert

Atomic updater types:

  • AtomicIntegerFieldUpdater

  • AtomicLongFieldUpdater

  • AtomicReferenceFieldUpdater

Adder types:

  • LongAdder

Common assertions

This section describes the assertions common to all types, the Javadoc for common assertions methods is available here.

Object assertions

The Javadoc for Object assertions is available here.

String/CharSequence assertions

This section describes all the available assertions for CharSequence (including String, StringBuilder, StringBuffer, …​):

The Javadoc for CharSequence assertions is available here.