Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

multiple check() invocations on the same mock cause IllegalStateException #134

Closed
StepanOvsyankin opened this issue Dec 6, 2016 · 1 comment
Assignees
Labels
type:bug Behavior not according to spec
Milestone

Comments

@StepanOvsyankin
Copy link

interface HelloSrv {
    fun sayHello(to: String): String
}

...
mock<HelloSrv> {
    on { sayHello(check {  }) } doReturn ""
    on { sayHello(check {  }) } doReturn "" // <-- fails here
}
java.lang.IllegalStateException: it must not be null

	at kkk.command.AnyTest$should create non-null values$1$1$$special$$inlined$check$1.matches(Mockito.kt:57)
	at org.mockito.internal.invocation.TypeSafeMatching.apply(TypeSafeMatching.java:24)
	at org.mockito.internal.invocation.MatcherApplicationStrategy.forEachMatcherAndArgument(MatcherApplicationStrategy.java:82)
	at org.mockito.internal.invocation.InvocationMatcher.argumentsMatch(InvocationMatcher.java:152)
	at org.mockito.internal.invocation.InvocationMatcher.matches(InvocationMatcher.java:81)
	at org.mockito.internal.stubbing.InvocationContainerImpl.findAnswerFor(InvocationContainerImpl.java:82)
	at org.mockito.internal.handler.MockHandlerImpl.handle(MockHandlerImpl.java:88)
	at org.mockito.internal.handler.NullResultGuardian.handle(NullResultGuardian.java:32)
	at org.mockito.internal.handler.InvocationNotifierHandler.handle(InvocationNotifierHandler.java:36)
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor.doIntercept(MockMethodInterceptor.java:41)
	at org.mockito.internal.creation.bytebuddy.MockMethodInterceptor$DispatcherDefaultingToRealMethod.interceptAbstract(MockMethodInterceptor.java:120)
	at kkk.command.HelloSrv$MockitoMock$813194496.sayHello(Unknown Source)
	at kkk.command.AnyTest$should create non-null values$1$2.invoke(AnyTest.kt:15)
	at kkk.command.AnyTest$should create non-null values$1$2.invoke(AnyTest.kt:9)
	at com.nhaarman.mockito_kotlin.KStubbing.on(Mockito.kt:119)
	at kkk.command.AnyTest.should create non-null values(AnyTest.kt:15)

mockito-kotlin: 1.0.0
mockito: 2.2.28

@nhaarman
Copy link
Collaborator

nhaarman commented Dec 7, 2016

Note that check is not for usage while stubbing, only for verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Behavior not according to spec
Projects
None yet
Development

No branches or pull requests

2 participants