Top Description Methods
org.easymock

public @Interface Mock

extends Annotation
Annotations
@Target:FIELD, ANNOTATION_TYPE
@Retention:RUNTIME
@Documented
Imports
java.lang.annotation.*

Annotation to set on a field so that EasyMockRunner, EasyMockRule or EasyMockSupport#injectMocks(Object) will inject a mock to it.

Doing
@Mock private MyClass mock;
is strictly identical to doing
private MyClass mock = createMock(MyClass.class);

Author
Henri Tremblay
Since
3.2

Method Summary

Modifier and TypeMethod and Description
public String

Returns:

name of the field to inject to
fieldName
()

Name of the test subject field to which this mock will be assigned.

public String

Returns:

name of the mock to be created. By default, it is the "EasyMock for field TypeName.fieldName
name
()

public MockType

Returns:

type of mock to create
type
()

public MockType

Returns:

type of mock to create. It is an alias of type()
value
()

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString

Method Detail

fieldNameback to summary
public String fieldName()

Name of the test subject field to which this mock will be assigned. Use to disambiguate the case where a mock may be assigned to multiple fields of the same type. When set, this mock will be assigned to the given field name in any test subject with a matching field name. If not set, injection is to all type-compatible fields in all test subjects. A given field name may only be used once, and there must be a matching field in at least one test subject.

Returns:String

name of the field to inject to

nameback to summary
public String name()
Returns:String

name of the mock to be created. By default, it is the "EasyMock for field TypeName.fieldName

typeback to summary
public MockType type()
Returns:MockType

type of mock to create

valueback to summary
public MockType value()
Returns:MockType

type of mock to create. It is an alias of type()

Since
3.5