AssertJ

김승규·2024년 2월 26일

assertThat

Assertions.assertThat(actual).isEquealTo(expected);

softly

SoftAssertions.assertSoftly(softly -> {
	softly.assertThat(orderItem.getOrderId()).isEqualTo(1001L);
    softly.assertThat(orderItem.getLineNumber()).isEqualTo(1);
    // ...
});

usingRecursiveComparison

assertThat(result.getNowCategoryRoute()).usingRecursiveComparison().isEqualTo(expectedRoute);

isNull, isEmpth

SoftAssertions.assertSoftly(softly -> {
    assertThat(result.getNowCategoryRoute()).isNull();
    assertThat(result.getChildrenCategoryList()).isEmpty();
});

Exception

assertThatThrownBy(() -> cartService.addBookToCart(request))
                    .isInstanceOf(CartBadRequestException.class)
                    .hasMessageContaining("User not found (user id: 1)");
profile
꿈꾸는 리얼리스트 개발자 김승규입니다.

0개의 댓글