@Mock Annotation



@Mock
It is the most widely used annotation in Mockito. 
You can apply this annotation on any Field which you want to mock.
This annotation is used to create mock object for any class and interface. 
To use this annotation you need to call MockitoAnnotations.initMocks(this); in your init or setup method.
It Minimizes repetitive mock creation code.
It Makes the test class more readable.
It Allows shorthand creation of objects required for testing any logical code.
Mock object calls any method then 
method will return 0 incase if the method return type is primitive,
method will return empty collection if it return type is collections.
method will return false if method return type is boolean.

Example:
interface IHello{
public String getName();
}

class CHello{
public String getName(){return "Hello";};
}

public class MockAnnotationAndMethodTest {

@Mock IHello iHello;
@Mock CHello chello;

@Before
public void init(){
MockitoAnnotations.initMocks(this);
}

@Test
public void test_Interface_And_class_Object_With_Mock_Annotation(){
chello.getName();
iHello.getName();
}
}