Answer by Jeff Bowman for Mockito Capture is not maintaining captured list at...
To agree with Vlasec's answer, it wouldn't make sense for Mockito to deep copy by default. It won't be able to tell which objects are immutable value objects (like String), which are easy to copy...
View ArticleAnswer by user3458 for Mockito Capture is not maintaining captured list at...
One way to deal with this is to call doAnswer(invocationOnMock -> {return null;}).when(listPrinter).printList(any());And then in the hook do your own capture with deep copy, or verify in place.
View ArticleAnswer by Vlasec for Mockito Capture is not maintaining captured list at time...
It might sound like an amazing feature, but then think about it that way: If it was making a copy, where should it stop? You could possibly capture some object that has many references to other objects...
View ArticleAnswer by alayor for Mockito Capture is not maintaining captured list at time...
This is happening because Mockito maintains a reference to the object passed as a parameter.You can try this.private void simulateFailSituation() { list.add("Pip"); listPrinter.printList(new...
View ArticleMockito Capture is not maintaining captured list at time of capturing
In Mockito we have a situation where the capture of a list doesn't return the expected result. Test case:We add "Pip" to a list We capture the listWe add "Sok" to the list.In our assert we only expect...
View Article
More Pages to Explore .....