Tags » Mockito

How to mock setters and why would we do that?

When we write unit tests we start replacing our objects with all kind of fakes. We call this process mocking. We do it because we want to test our logic in isolation. 781 more words


ArgumentCaptor vs InOrder to verify subsequent callbacks with different arguments

I was testing my DAO class generated using the Room library from Architecture Components. I wanted to check that the LiveData returned by a query joining multiple tables was going to be updated when data changes. 612 more words


Are you verifying your stubs?

What is stubbing? What is verifying? Do we need both? If we look into the java docs for Mockito.when() (stubbing) and Mockito.verify() 880 more words
Test Your Code

An example : Unit test using Argument Captor

How do you write unit test for the argument of a method call inside the method which returns void?

Have a look at the code snippet below: 109 more words


Modern TDD-oriented Java 8 JUnit test template for Idea (with Mockito and AssertJ)

Tune up your JUnit test class template for Idea with the BDD-like syntax, Java 8 and the Mockito-AssertJ duo.

Topics covered in this article may seem trivial.

1,015 more words
Tricks & Tips