Answers:
您可以使用IsNull.nullValue()方法:
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
assertThat(attr.getValue(), is(nullValue()));IsNull它是该类中的静态方法。只是做static import,还是用IsNull.nullValue()。
                    import static org.hamcrest.core.IsNull.nullValue;到您的课程。
                    import static org.hamcrest.CoreMatchers.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);