<dependency>
<groupId>io.github.ones1kk</groupId>
<artifactId>assertions</artifactId>
<version>1.0.0</version>
</dependency>
implementation group: 'io.github', name: 'assertions', version: '1.0.0'
implementation 'io.github.ones1kk:assertions:1.0.0'
- Verifies assertions for JDK types.
- Provides assertions in the form of method chaining.
- Overrides error message by writing custom description.
- Customizes error message format.
import io.github.ones1kk.assertion.core.description.formatter.Formattable;
List<String> actual = List.of("1", "2", "3", "4");
List<String> expected = List.of("1");
class CustomFormat implements Formattable {
...override methods
}
Asserts.that(actual)
// customize error message format by using configure method.
.configure(new CustomFormat())
// write custom error message by using as method .
.as("The given 'actual' should not be empty and be null.")
.isNotEmptyOrNull()
// write custom error message about next assertion.
.as("The given 'actual' should contain one of '{}, {}'.", "1", "2", "a")
.containsAny("1", "2", "a")
.as("The given 'actual' should not contain null.")
.doesNotContainNull()
// if above assertions are paased, then if below assertions are failed, default error message will be printed.
// check the given 'actual' size.
.hasSize(4)
// The size of given 'actual' should be larger than the size of given 'expected'.
.isLargerThan(expecred);
AssertJ - Fluent assertions java library