How to assertThat something is null with Hamcrest?

前端 未结 4 715
青春惊慌失措
青春惊慌失措 2021-02-01 00:12

How would I assertThat something is null?

for example

 assertThat(attr.getValue(), is(\"\"));

But I get an e

4条回答
  •  北海茫月
    2021-02-01 00:45

    Use the following (from Hamcrest):

    assertThat(attr.getValue(), is(nullValue()));
    

    In Kotlin is is reserved so use:

    assertThat(attr.getValue(), `is`(nullValue()));
    

提交回复
热议问题