Mockito now preserves annotations on mocked methods and types as well as generic meta data. Previously, a mock type did not preserve annotations on types unless they were explicitly inherited and never retained annotations on methods. As a consequence, the following conditions now hold true: @MyAnnotation class Foo { List<String> bar() { ... } }
With Java 8 this method will be removed in Mockito 3.0. This method is only used for generic friendliness to avoid casting, this is not anymore needed in Java 8.
Mockito will try to inject mocks only either by constructor injection, setter injection, or property injection in order and as described below. If any of the following strategy fail, then Mockito won't report failure; i.e. you will have to provide dependencies yourself.
Initializes objects annotated with Mockito annotations for given testClass: @ Mock, @ Spy, @ Captor, @ InjectMocks See examples in javadoc for MockitoAnnotations class.