We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
itAnswers
In order to return the first argument using the infix notations, this is what I am required to do without any additional functions:
When calling questionService.updateQuestion(any()) itAnswers { it.getArgument(0) }
Rather, in the original Mockito or even in com.nhaarman:mockito-kotlin I can do this notation:
com.nhaarman:mockito-kotlin
whenever(questionService.updateQuestion(any())).then(returnsFirstArg<Question>())
In order to achieve this, I must use the following function that should be added to your API:
infix fun <T> OngoingStubbing<T>.itAnswers(value: Answer<T>): OngoingStubbing<T> = this.thenAnswer(value)
You could also include these to make the grammar more accurate with the arguments:
fun <T> withFirstArg(): Answer<T> = org.mockito.AdditionalAnswers.returnsFirstArg() fun <T> withSecondArg(): Answer<T> = org.mockito.AdditionalAnswers.returnsSecondArg() fun <T> withThirdArg(): Answer<T> = org.mockito.AdditionalAnswers.returnsArgAt(3) fun <T> withFourthArg(): Answer<T> = org.mockito.AdditionalAnswers.returnsArgAt(4) fun <T> withLastArg(): Answer<T> = org.mockito.AdditionalAnswers.returnsLastArg()
The combination of this all allows me to do the following:
When calling questionRepo.save(any(Question::class)) itAnswers withFirstArg()
The text was updated successfully, but these errors were encountered:
e3ad0d9
Merge pull request #84 from jpopadak/master
6c80b01
Resolves #83 - `itAnswers` should allow original Mockito Answer types
I've just released v1.32 which contains these changes 👍
Sorry, something went wrong.
No branches or pull requests
In order to return the first argument using the infix notations, this is what I am required to do without any additional functions:
When calling questionService.updateQuestion(any()) itAnswers { it.getArgument(0) }
Rather, in the original Mockito or even in
com.nhaarman:mockito-kotlin
I can do this notation:whenever(questionService.updateQuestion(any())).then(returnsFirstArg<Question>())
In order to achieve this, I must use the following function that should be added to your API:
infix fun <T> OngoingStubbing<T>.itAnswers(value: Answer<T>): OngoingStubbing<T> = this.thenAnswer(value)
You could also include these to make the grammar more accurate with the arguments:
The combination of this all allows me to do the following:
When calling questionRepo.save(any(Question::class)) itAnswers withFirstArg()
The text was updated successfully, but these errors were encountered: