Update OngoingStubbing to take a Supplier<T>
See original GitHub issueCurrently the OngoingStubbing interface only supports single values or varargs as part of the thenReturn()
method. This method should be overloaded to include thenReturn(Supplier<T>)
. This feature will users testing streaming processes by being able to have new objects generated for each iteration through their pipeline.
Issue Analytics
- State:
- Created 5 years ago
- Reactions:7
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Java Generics - method not applicable to Mockito generated ...
static <T> OngoingStubbing<T> whenX( Supplier<T> sup ) { return Mockito.when( sup.get() ); } whenX(thingsProvider::getThings).
Read more >OngoingStubbing (Mockito 2.2.9 API) - javadoc.io
Sets a generic Answer for the method. Sets the real implementation to be called when the method is called on a mock object....
Read more >JUnit 5 tutorial, part 1: Unit testing with JUnit 5, Mockito, and ...
Introduction to Mock objects using Mockito. Thus far we have only reviewed testing simple methods that do not rely on external dependencies, but ......
Read more >Implementing Mockito from Scratch
When running the class, the test succeeds. The goal is now to remove all Mockito import statements and to rewrite the minimal code...
Read more >Diff - platform/external/mockito - Google Git
-9,4 +9,4 @@ The source can be updated using the update_source.sh script. ... For partial mock it's recommended to use <code>doReturn</code> syntax.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Until it’s changed, because Answer is a functional interface, you can use
thenAnswer
andthen
like this:Or
Or
The latter of @ZeLarpMaster 's snippets helped out with the
doAnswer()
variant for spies. I completely forgot about theAnswer
interface, but it does the job here as well: