本文整理了Java中org.mockito.Mockito.mockitoSession()
方法的一些代码示例,展示了Mockito.mockitoSession()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mockito.mockitoSession()
方法的具体详情如下:
包路径:org.mockito.Mockito
类名称:Mockito
方法名:mockitoSession
[英]MockitoSession is an optional, highly recommended feature that helps driving cleaner tests by eliminating boilerplate code and adding extra validation.
For more information, including use cases and sample code, see the javadoc for MockitoSession.
[中]MockitoSession是一个可选的、强烈推荐的功能,它通过消除样板代码和添加额外的验证来帮助驱动更干净的测试。
有关更多信息,包括用例和示例代码,请参阅javadoc For MockitoSession。
代码示例来源:origin: org.mockito/mockito-core
public void evaluate() throws Throwable {
if (session == null) {
session = Mockito.mockitoSession()
.name(target.getClass().getSimpleName() + "." + method.getName())
.strictness(strictness)
.logger(new MockitoSessionLoggerAdapter(logger))
.initMocks(target)
.startMocking();
} else {
MockitoAnnotations.initMocks(target);
}
Throwable testFailure = evaluateSafely(base);
session.finishMocking(testFailure);
if (testFailure != null) {
throw testFailure;
}
}
代码示例来源:origin: linkedin/dexmaker
/**
* Same as {@link Mockito#mockitoSession()} but adds the ability to mock static methods
* calls via {@link StaticMockitoSessionBuilder#mockStatic(Class)},
* {@link StaticMockitoSessionBuilder#mockStatic(Class, Answer)}, and {@link
* StaticMockitoSessionBuilder#mockStatic(Class, MockSettings)};
* <p>All mocking spying will be removed once the session is finished.
*/
public static StaticMockitoSessionBuilder mockitoSession() {
return new StaticMockitoSessionBuilder(Mockito.mockitoSession());
}
代码示例来源:origin: molgenis/molgenis
@BeforeMethod
public void initMocks() {
mockitoSession = mockitoSession().initMocks(this).strictness(strictness).startMocking();
}
代码示例来源:origin: molgenis/molgenis
@BeforeMethod
public void initMocks() {
mockitoSession = mockitoSession().initMocks(this).strictness(strictness).startMocking();
}
代码示例来源:origin: org.mockito/junit-jupiter
/**
* 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) {
Set<Object> testInstances = new LinkedHashSet<>();
testInstances.add(context.getRequiredTestInstance());
this.collectParentTestInstances(context, testInstances);
Strictness actualStrictness = this.retrieveAnnotationFromTestClasses(context)
.map(MockitoSettings::strictness)
.orElse(strictness);
MockitoSession session = Mockito.mockitoSession()
.initMocks(testInstances.toArray())
.strictness(actualStrictness)
.startMocking();
context.getStore(MOCKITO).put(SESSION, session);
}
代码示例来源:origin: org.infinispan/infinispan-core
@BeforeMethod(alwaysRun = true)
public void setup() {
mockitoSession = Mockito.mockitoSession().strictness(Strictness.STRICT_STUBS).startMocking();
EventLogManager eventLogManager = new EventLogManagerImpl();
PersistentUUIDManager persistentUUIDManager = new PersistentUUIDManagerImpl();
EmbeddedCacheManager cacheManager = mock(EmbeddedCacheManager.class);
topologyManager = mock(ClusterTopologyManager.class);
transport = mock(Transport.class);
PreferAvailabilityStrategy availabilityStrategy =
new PreferAvailabilityStrategy(eventLogManager, persistentUUIDManager,
ClusterTopologyManagerImpl::distLostDataCheck);
status = new ClusterCacheStatus(cacheManager, CACHE_NAME, availabilityStrategy, RebalanceType.FOUR_PHASE,
topologyManager, transport, persistentUUIDManager, eventLogManager,
Optional.empty(), false);
}
代码示例来源:origin: org.infinispan/infinispan-core
@BeforeMethod(alwaysRun = true)
public void setup() {
mockitoSession = Mockito.mockitoSession()
.strictness(Strictness.STRICT_STUBS)
.startMocking();
persistentUUIDManager = new PersistentUUIDManagerImpl();
eventLogManager = new EventLogManagerImpl();
context = mock(AvailabilityStrategyContext.class);
persistentUUIDManager.addPersistentAddressMapping(A, persistentUUID(A));
persistentUUIDManager.addPersistentAddressMapping(B, persistentUUID(B));
persistentUUIDManager.addPersistentAddressMapping(C, persistentUUID(C));
strategy = new PreferAvailabilityStrategy(eventLogManager, persistentUUIDManager,
ClusterTopologyManagerImpl::distLostDataCheck);
}
内容来源于网络,如有侵权,请联系作者删除!