Search in sources :

Example 1 with MockitoSessionLoggerAdapter

use of org.mockito.internal.session.MockitoSessionLoggerAdapter in project mockito by mockito.

the class MockitoExtension method beforeEach.

/**
 * Callback that is invoked <em>before</em> each test is invoked.
 *
 * @param context the current extension context; never {@code null}
 */
@Override
public void beforeEach(final ExtensionContext context) {
    List<Object> testInstances = context.getRequiredTestInstances().getAllInstances();
    Strictness actualStrictness = this.retrieveAnnotationFromTestClasses(context).map(MockitoSettings::strictness).orElse(strictness);
    MockitoSession session = Mockito.mockitoSession().initMocks(testInstances.toArray()).strictness(actualStrictness).logger(new MockitoSessionLoggerAdapter(Plugins.getMockitoLogger())).startMocking();
    context.getStore(MOCKITO).put(MOCKS, new HashSet<>());
    context.getStore(MOCKITO).put(SESSION, session);
}
Also used : MockitoSession(org.mockito.MockitoSession) MockitoSessionLoggerAdapter(org.mockito.internal.session.MockitoSessionLoggerAdapter) Strictness(org.mockito.quality.Strictness)

Aggregations

MockitoSession (org.mockito.MockitoSession)1 MockitoSessionLoggerAdapter (org.mockito.internal.session.MockitoSessionLoggerAdapter)1 Strictness (org.mockito.quality.Strictness)1