프로그래밍 노트/TEST를 해보자

Hmacrest 프레임워크 사용하기_2

깡냉쓰 2019. 11. 13. 22:30
728x90
반응형

Type별로 중요한 matcher들을 정리

Core

  • anything
  • describedAs
  • is

Logical

  • allOf : 모든 조건 만족시 참 (like Java &&)
  • anyOf : 조건 중 하나 만족시 참 (like Java ||)
  • not : 비교 결과 부정 또는 다름

Objects

  • equalTo
  • hasToString
  • instanceOf, isCompatibleType
  • notNullValue, nullValue
  • sameInstance

Numbers

  • closeTo
  • greaterThan, greaterThanOrEqualTo, lessThan, lessThanOrEqualTo

Beans

  • hasProperty

Collections

  • array
  • hasEntry, hasKey, hasValue
  • hasItem, hasItems
  • hasItemInArray

Text

  • equalToIgnoringCase
  • equalToIgnoringWhiteSpace
  • containsString, endsWith, startsWith
@Test
public void test(){
        String str = null;
        assertThat(str, is(nullValue());
}

 

출처 : https://www.lesstif.com/pages/viewpage.action?pageId=18219426

728x90
반응형