mockito-core-2.23.4.jar
登录
|
org.mockito:mockito-core:2.23.4
META-INF
org
mockito
session
package-info.java
MockitoSession.java
MockitoAnnotations.java
internal
session
package-info.java
configuration
creation
matchers
MockitoCore.java
reporting
util
InternalMockHandler.java
handler
listeners
exceptions
framework
runners
invocation
stubbing
debugging
progress
junit
JUnitRule.java
TestFinishedEvent.java
DefaultStubbingLookupListener.java
package-info.java
NoOpTestListener.java
DefaultTestFinishedEvent.java
MismatchReportingTestListener.java
UniversalTestListener.java
StubbingArgMismatches.java
util
UnusedStubbingsFinder.java
UnnecessaryStubbingsReporter.java
StrictStubsRunnerTestListener.java
ArgMismatchFinder.java
UnusedStubbings.java
ExceptionFactory.java
StubbingHint.java
VerificationCollectorImpl.java
MockitoTestListener.java
verification
hamcrest
InOrderImpl.java
Matchers.java
configuration
creation
Captor.java
InjectMocks.java
plugins
ArgumentMatchers.java
InOrder.java
Incubating.java
BDDMockito.java
MockitoFramework.java
MockingDetails.java
quality
AdditionalMatchers.java
ArgumentCaptor.java
Spy.java
codegen
mock
NotExtensible.java
listeners
exceptions
Mockito.java
runners
invocation
CheckReturnValue.java
stubbing
Answers.java
Mock.java
ArgumentMatcher.java
junit
AdditionalAnswers.java
verification
hamcrest
MockSettings.java
MockitoDebugger.java
LICENSE
DefaultStubbingLookupListener.java
清空
类结构
/* * Copyright (c) 2017 Mockito contributors * This program is made available under the terms of the MIT License. */ package org.mockito.internal.junit; import org.mockito.internal.exceptions.
Reporter
; import org.mockito.internal.listeners.
StubbingLookupEvent
; import org.mockito.internal.listeners.
StubbingLookupListener
; import org.mockito.internal.stubbing.
UnusedStubbingReporting
; import org.mockito.invocation.
Invocation
; import org.mockito.quality.
Strictness
; import org.mockito.stubbing.
Stubbing
; import java.util.
Collection
; import java.util.
LinkedList
; import java.util.
List
; import static org.mockito.internal.stubbing.
StrictnessSelector
.determineStrictness; /** * Default implementation of stubbing lookup listener. * Fails early if stub called with unexpected arguments, but only if current strictness is set to STRICT_STUBS. */ class
DefaultStubbingLookupListener
implements
StubbingLookupListener
{ private
Strictness
currentStrictness
; private boolean
mismatchesReported
;
DefaultStubbingLookupListener
(
Strictness
strictness
) { this.
currentStrictness
=
strictness
; } public void
onStubbingLookup
(
StubbingLookupEvent
event
) {
Strictness
actualStrictness
=
determineStrictness
(
event
.
getStubbingFound
(),
event
.
getMockSettings
(),
currentStrictness
); if (
actualStrictness
!=
Strictness
.
STRICT_STUBS
) { return; } if (
event
.
getStubbingFound
() == null) { //If stubbing was not found for invocation it means that either the mock invocation was not stubbed or //we have a stubbing arg mismatch.
List
<
Invocation
>
argMismatchStubbings
=
potentialArgMismatches
(
event
.
getInvocation
(),
event
.
getAllStubbings
()); if (!
argMismatchStubbings
.
isEmpty
()) {
mismatchesReported
= true;
Reporter
.
potentialStubbingProblem
(
event
.
getInvocation
(),
argMismatchStubbings
); } } else { //when strict stubs are in use, every time a stub is realized in the code it is implicitly marked as verified //this way, the users don't have to repeat themselves to verify stubbed invocations (DRY)
event
.
getInvocation
().
markVerified
(); } } private static
List
<
Invocation
>
potentialArgMismatches
(
Invocation
invocation
,
Collection
<
Stubbing
>
stubbings
) {
List
<
Invocation
>
matchingStubbings
= new
LinkedList
<
Invocation
>(); for (
Stubbing
s
:
stubbings
) { if (
UnusedStubbingReporting
.
shouldBeReported
(
s
) &&
s
.
getInvocation
().
getMethod
().
getName
().
equals
(
invocation
.
getMethod
().
getName
())) {
matchingStubbings
.
add
(
s
.
getInvocation
()); } } return
matchingStubbings
; } /** * Enables resetting the strictness to desired level */ void
setCurrentStrictness
(
Strictness
currentStrictness
) { this.
currentStrictness
=
currentStrictness
; } /** * Indicates that stubbing argument mismatch was reported */ boolean
isMismatchesReported
() { return
mismatchesReported
; } }
查找资源
Jre/Lib
输入类名或文件名
类结构窗口