I'm trying to make a unit test with @InjectMocks
and @Mock
.
@RunWith(MockitoJUnitRunner.class)
public class ProblemDefinitionTest {
@InjectMocks
ProblemDefinition problemDefinition;
@Mock
Matrix matrixMock;
@Test
public void sanityCheck() {
Assert.assertNotNull(problemDefinition);
Assert.assertNotNull(matrixMock);
}
}
When I don't include the @RunWith
annotation, the test fails. But
The type MockitoJUnitRunner is deprecated
I'm using Mockito 2.6.9. How should I go about this?
org.mockito.runners.MockitoJUnitRunner
is now indeed deprecated, you are supposed to use org.mockito.junit.MockitoJUnitRunner
instead. As you can see only the package name has changed, the simple name of the class is still MockitoJUnitRunner
.
Excerpt from the javadoc of org.mockito.runners.MockitoJUnitRunner
:
Moved to
MockitoJUnitRunner
, this class will be removed with Mockito 3