Tags » Mockito

More compact Mockito with Java 8, lambda expressions and Mockito-Java8 add-ons

Mockito-Java8 is a set of Mockito add-ons leveraging Java 8 and lambda expressions to make mocking with Mockito even more compact.

At the beginning of 2015 I gave my flash talk…

513 more words

anyString() v/s anyString() in Mocking frameworks

So I was trying out mocking frameworks for the first time a few days ago, and there’s an interesting observation: even though EasyMock, PowerMock… 361 more words


Stubbing a var arg method using Mockito

I had a need to stub a method the other day that had a var arg method. I failed in stubbing it using Mockito. It disturb me a lot. 259 more words


Scala in Business | Knoldus Newsletter - April 2015

Hello Folks

We are back again with AprilĀ 2015, Newsletter. Here is this Scala in Business | Knoldus Newsletter – April 2015

In this newsletter, you will get the business related news for… 49 more words


The Power of thenAnswer


when(myMock.method(myObject)).thenAnswer(Answer<?> answer);


doAnswer(Answer<?> answer).when(myMock).method(myObject);

Use case 1:

You can mock/stub void methods (as i explain in this post) to simulate the behaviour of them, which then will i.e. 728 more words


Mockito Deep Stubs Example

This tutorial tries to explain how to use Mockito’s Deep Stubs feature.

When you’ve situations where your class under test has multiple levels of dependencies, … 322 more words


How to mock void methods?

Void methods on mocks do nothing by default. But if we have to spy our objects in order to mock just a part of it, we may also have to mock the void methods. 303 more words