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

About ChandanPandey

Try to come up with a good design as by product of good coding practices

Posted on November 22, 2013, in TDD and tagged , , , . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: