assertThat
1. String 일 때,
assertThat("Hello, world!")
.isNotEmpty() // 비어있지 않음
.contains("Nice") // "Nice"를 포함
.doesNotContain("ㅁㅁㅁ") // "ㅁㅁㅁ"는 포함하지 않음
.startsWith("He") // "He"로 시작하는 가?
.endsWith("!") // "!"로 끝난다.
.isEqualTo("Hello, world! ^^."); // "Hello, world! ^^."와 같다.
2. 숫자일 때,
assertThat(10.02d)
.isPositive() // 양수
.isGreaterThan(1) // 3보다 크냐?
.isLessThan(2) // 4보다 작냐?
.isEqualTo(10, offset(1d)) // 오프셋 1 기준으로 10과 같음?
.isEqualTo(10.0, offset(0.1d)) // 오프셋 0.1 기준으로10.0과 같음?
.isEqualTo(10.02); // 오프셋 없이는 10.02와 같음?
'개발 > JAVA' 카테고리의 다른 글
Math.random() (0) | 2018.08.07 |
---|---|
null 대신 Optional (0) | 2018.07.07 |
BigDecimal 사용법 (0) | 2018.06.03 |
string.join 사용기 (0) | 2018.05.14 |
자바 스트림, Stream (0) | 2018.03.30 |