Search in sources :

Example 1 with GlobalConfiguration

use of org.mockito.internal.configuration.GlobalConfiguration in project mockito by mockito.

the class MockitoAnnotations method initMocks.

/**
     * Initializes objects annotated with Mockito annotations for given testClass:
     *  @{@link org.mockito.Mock}, @{@link Spy}, @{@link Captor}, @{@link InjectMocks}
     * <p>
     * See examples in javadoc for {@link MockitoAnnotations} class.
     */
public static void initMocks(Object testClass) {
    if (testClass == null) {
        throw new MockitoException("testClass cannot be null. For info how to use @Mock annotations see examples in javadoc for MockitoAnnotations class");
    }
    AnnotationEngine annotationEngine = new GlobalConfiguration().tryGetPluginAnnotationEngine();
    annotationEngine.process(testClass.getClass(), testClass);
}
Also used : GlobalConfiguration(org.mockito.internal.configuration.GlobalConfiguration) MockitoException(org.mockito.exceptions.base.MockitoException) AnnotationEngine(org.mockito.plugins.AnnotationEngine)

Aggregations

MockitoException (org.mockito.exceptions.base.MockitoException)1 GlobalConfiguration (org.mockito.internal.configuration.GlobalConfiguration)1 AnnotationEngine (org.mockito.plugins.AnnotationEngine)1