マニュアル: AssertJ

投稿日: 更新日:

自分が書いた記事

Maven, Gradleなどの設定

Quick startの1を参照。

Timestampの比較

assertThat(timestamp).hasSameTimeAs("2017-05-19");

see. https://github.com/joel-costigliola/assertj-core/issues/273

BigDecimalの比較

assertThat(num).isEqualTo("1");

Mapの比較

assertThat(map).containsEntry(key, value);

Optionalの中身の比較

http://joel-costigliola.github.io/assertj/core-8/api/org/assertj/core/api/AbstractOptionalAssert.html#hasValueSatisfying-java.util.function.Consumer-

assertThat(optional).hasValueSatisfying((value) -> { ... });