반응형
Hamcrest에서 무언가가 null인지 어떻게 주장합니까?
어떻게겠습니까 나는 assertThat뭔가 null?
예를 들어
assertThat(attr.getValue(), is(""));
하지만 내가 가질 수 없다는 오류 수 null에를 is(null).
당신은 IsNull.nullValue()방법 을 사용할 수 있습니다 :
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
assertThat(attr.getValue(), is(nullValue()));
왜 사용 assertNull(object)/를 assertNotNull(object)?
원하는 경우 할 hamcrest수 있습니다
import static org.hamcrest.Matchers.nullValue;
assertThat(attr.getValue(), is(nullValue()));
에서에게 Junit당신이 할 수있는
import static junit.framework.Assert.assertNull;
assertNull(object);
Hamcrest에서 다음을 사용하십시오.
assertThat(attr.getValue(), is(nullValue()));
참고 URL : https://stackoverflow.com/questions/18987692/how-to-assertthat-something-is-null-with-hamcrest
반응형
'Programming' 카테고리의 다른 글
| Java 클래스가 비슷한 것을 구현해야하는 이유는 무엇입니까? (0) | 2020.06.28 |
|---|---|
| Python 프로그램을 C / C ++ 코드로 변환 하시겠습니까? (0) | 2020.06.28 |
| NSDate를 연도, 월, 일 및시, 분, 초 모두에 대해 특정 스타일로 포맷 (0) | 2020.06.28 |
| 한 명의 사용자가 수정 한 모든 파일을 git에게 알려줄 수 있습니까? (0) | 2020.06.28 |
| VARCHAR (255)이 너무 자주 사용되는 다른 이유가 있습니까? (0) | 2020.06.28 |