どのように私assertThatはnull何かですか?
例えば
assertThat(attr.getValue(), is(""));
しかし、私はに入れることができないというエラーが表示さnullれis(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()));
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);