Package org.jvnet.testing.hk2mockito
Annotation Interface MC
@MC (Mock Collaborator) annotation is used on fields and methods
of a Test class to inject a mock of the @SUT's collaborating
services.
- Author:
- Sharmarke Aden
- See Also:
-
MockSettings
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionorg.mockito.AnswersSpecifies default answers to interactions.Class<?>[]Specifies extra interfaces the mock should implement.If the collaborator service being injected is a field of the SUT, this value should indicate the name of the field.Specifies mock name.intIf the collaborator service being injected is a constructor or method parameter of the SUT, this value should indicate the index of the parameter.
-
Element Details
-
value
int valueIf the collaborator service being injected is a constructor or method parameter of the SUT, this value should indicate the index of the parameter. By default the collaborator will be detected but in instances (i.e. injecting two or more services with the same type) you may want to explicitly specify the index of the service.- Returns:
- the index of the parameter.
- Default:
- -1
-
field
String fieldIf the collaborator service being injected is a field of the SUT, this value should indicate the name of the field. By default the @SC field name is used as the collaborator field name but in instances (i.e. field injection of two or more services with the same type) you may want to explicitly specify the name of the field.- Returns:
- the name of the field.
- Default:
- ""
-
answer
org.mockito.Answers answerSpecifies default answers to interactions.- Returns:
- default answer to be used by mock when not stubbed.
- Default:
- RETURNS_DEFAULTS
-
name
String nameSpecifies mock name. Naming mocks can be helpful for debugging - the name is used in all verification errors. By default the field name will be used as mock name.- Returns:
- the name of the mock.
- Default:
- ""
-
extraInterfaces
Class<?>[] extraInterfacesSpecifies extra interfaces the mock should implement. Might be useful for legacy code or some corner cases. For background, see issue 51 here- Returns:
- extra interfaces that should be implemented.
- Default:
- {}
-