Blog Archives

Mock annotation returning null for mocked object


Using mockito and had written

@Mock
private SomeService someService;

This was returning NULL and my test cases were failing -What was the missing element – a one liner

@RunWith(MockitoJUnitRunner.class)
public class SomeClass{

Which is needed for @Mock annotation to work!

Advertisements