My code for junit is
@Autowired
private ABC abc;
@Test
public void checkZonePresent() {
assertThat(abc.getZoneList().size()).isEqualTo(1);
}
SO, here I am getting error like java.lang.nullpointer exception
My code for junit is
@Autowired
private ABC abc;
@Test
public void checkZonePresent() {
assertThat(abc.getZoneList().size()).isEqualTo(1);
}
SO, here I am getting error like java.lang.nullpointer exception
At first glance abc.getZoneList() is null. But also NPE might if you didn't configured tests with spring (didn't ). It's difficult to say without code , show pls how you configured test class
zero step (in your case it helps , but in general you don't need to test it if you configured spring tests) :
assertThat(abc ,is(notNullValue());
First you should check that :
assertThat(abc.getZoneList(),is(notNullValue());
and looks like ,abc.getZoneList() ,it's a problem the next check should be
assertThat(abc.getZoneList().size()).isEqualTo(1)
your test fail and there is no explanation why, but test should explains what's going wrong