I have a method like this:
public void foo(@Nonnull String value) {...}
I would like to write unit test to make sure that it foo()throws NPE when valueis null, but I can not, because the compiler refuses to compile unit test when analyzing the flow of static null pointers enabled in the IDE.
How to make this test compiler (in Eclipse with "Enable annotation-based zero analysis" enabled):
@Test(expected = NullPointerException.class)
public void test() {
T inst = ...
inst.foo(null);
}
Note. Theoretically, a static compiler null pointer should prevent such cases. But there is nothing that would prevent someone from writing another module with the static flow analysis turned off and the method nullcalled with .
: . . , , , .
, , . , .
: , ", " ( , , ... ). , , , , @Nonnull?