1) Assertions 클래스란?
- 다른 타입의 assertion 메소드들에 대한 진입점입니다.
이 클래스안에 있는 각각의 메소드는 타입 구체적인 assertion 객체에 대한 정적 팩토리입니다.
예를 들어, 다음과 같이 활용할 수 있습니다.
int removed = employees.removeFired();
assertThat(removed).isZero();
List<Employee> newEmployees = employees.hired(today);
assertThat(newEmployees).hasSize(6);
2) assertThatThrownBy
- Throwable에 assert하는 것을 가능하게 합니다.
이 메소드는 as(String, Object...) 을 사용하는것과 같은 방식으로 assertion 묘사를 합니다.
@Test
public void testException(){
assertThatThrownBy(() -> throw new Exception("boom"); , "Test explosive code");
}
참고
Assertions (AssertJ fluent assertions 3.12.0 API) (joel-costigliola.github.io)
'테스트' 카테고리의 다른 글
Mockito 소개 (0) | 2022.09.02 |
---|---|
JUnit 5 기초 (0) | 2022.08.20 |