Success case
- assertThat(실제 값).isEqualTo(예상 값)
ex) assertThat(disCount).isEqualTo(1000);
import static org.assertj.core.api.Assertions.assertThat;
@Test
@DisplayName("Vip는 10% 적용되어야 한다")
void vip_o(){
Member memberA = new Member(1L, "memberA", Grade.VIP);
int disCount = discountPolicy.disCount(memberA, 10000);
assertThat(disCount).isEqualTo(1000);
}
Exception case
- assertThrows(실행할 로직에서 터질 exception.class, () -> 실행해야 할 로직);
ex) assertThrows(NoSuchBeanDefinitionException.class, () -> ac.getBean("xxxxxx", MemberService.class));
import static org.junit.jupiter.api.Assertions.*;
@Test
@DisplayName("빈이름으로 조회 X")
void findByBeanX() {
assertThrows(NoSuchBeanDefinitionException.class, () -> ac.getBean("xxxxxx", MemberService.class));
}