I am mocking a object using @Mock
annotation
@Mock
Customer customer;
but the @Mock
annotation is showing warning
The type MockitoAnnotations.Mock is deprecated
and my test case is failed
I am mocking a object using @Mock
annotation
@Mock
Customer customer;
but the @Mock
annotation is showing warning
The type MockitoAnnotations.Mock is deprecated
and my test case is failed
You are using the wrong mock. Try using the below one
org.mockito.Mock
instead of org.mockito.MockitoAnnotations.Mock
You may consider removing the deprecated
@BeforeEach
void init() {
MockitoAnnotations.initMocks(this);
}
and replace it with this rule inside the class
@Rule //initMocks
public MockitoRule rule = MockitoJUnit.rule();
I know this is late, but for those who run into this issue today you probably included the wrong dependency. Make sure to add:
testImplementation 'org.powermock:powermock-api-mockito2:2.0.2'
where it's mockito2.