Using @Mock and @InjectMocks

后端 未结 3 1440
旧巷少年郎
旧巷少年郎 2020-12-06 03:55

I\'m currently studying the Mockito framework and I\'ve created several test cases using Mockito. But then I read that instead of invoking mock(SomeClass.class) I c

3条回答
  •  不思量自难忘°
    2020-12-06 04:19

    O.K, I got my mistake!!! I've used the @InjectMocks but initialized the same variable in the init() method... So what happened was that mockito injected the mock objects to my variable - but seconds later I ran it over - initializing that very same variable!!!

提交回复
热议问题