Fluent Assertions for JUnit 5
Set of Fluent Assertions for Unit Tests. Inspired by FEST Fluent Assertions 2.x.
Latest release
The most recent release is fluent-assertions 0.5, released 2018-04-12.
The Maven group ID is de.toberkoe
, and the artifact ID is fluent-assertions
. Use
version 0.5
for the current version.
To add a dependency on fluent-assertions using Maven, use the following:
<dependency>
<groupId>de.toberkoe</groupId>
<artifactId>fluent-assertions</artifactId>
<version>0.5</version>
<scope>test</scope>
</dependency>
To add a dependency using Gradle:
dependencies {
testImplementation 'de.toberkoe:fluent-assertions:0.5'
}
Examples
Use de.toberkoe.fluentassertions.api.Assertions#assertThat
as entry point for type-specific fluent assertions.
To make tests more readable, it is recommended to access this class as a static import.
import static de.toberkoe.fluentassertions.api.Assertions.assertThat;
...
List<Integer> numbers = List.of(1, 2, 3, 4, 5);
assertThat(numbers)
.isNotEmpty()
.hasSizeOf(5)
.startsWith(1, 2, 3)
.doesNotHaveDuplicates();