如何断言Hamcrest的某些内容是无效的?
我怎么会是?assertThatnull
例如
assertThat(attr.getValue(), is(""));
但是我得到一个错误,说我不能在.nullis(null)
我怎么会是?assertThatnull
例如
assertThat(attr.getValue(), is(""));
但是我得到一个错误,说我不能在.nullis(null)
您可以使用 IsNull.nullValue() 方法:
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
assertThat(attr.getValue(), is(nullValue()));
为什么不使用 / ?assertNull(object)assertNotNull(object)