What method is used in AssertJ to check if an object is null?
A) isNull()
B) isEmpty()
C) isNotEmpty()
D) isPresent()
Answer:
A) isNull()
Explanation:
The isNull()
method in AssertJ is used to assert that an object is null. It checks whether the object reference is null
.
For example:
import static org.assertj.core.api.Assertions.assertThat;
Object obj = null;
assertThat(obj).isNull();
In this example, the isNull()
method asserts that the object obj
is null
.