I am a begginer in Spring and I need to write test for this class if it calls methods:
class ClassOne {
@Autowired
AutowiredClass a1;
@Autowired
AutowiredClass a2;
void methodOne() {
a1.method1();
}
void methodTwo() {
a2.method2();
}
}
I've tried to write test, but failed, got NPE:
class ClassOneTest {
@Autowired
ClassOneInterface c1i;
@Test
public void testMethod1() {
c1i.methodOne(); // <- NPE appears here..
Mockito.verify(ClassOne.class, Mockito.times(1));
}
}
Halp..
Would be great to successfully test void methods.
Aucun commentaire:
Enregistrer un commentaire