Make sure you initialize your mocks.
JUnit4
use @Before
@Before
public void setup() {
MockitoAnnotations.initMocks(this);
}
JUnit5
use @BeforeEach
@BeforeEach
public void setup() {
MockitoAnnotations.initMocks(this);
}
For JUnit5
check, you are using proper imports also.
import org.junit.runner.RunWith
import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)