If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Tuesday, September 10, 2013

Unit testing with Mockito

In this article I created a realistic scenario of services depending on each other. This article shows you how you can easily test business logic in isolation.


  1. Yay, test code :)
    When I use mocks, I also verify that they are called in the test.

    verify(temperatureService).predictTemperature(any(Date.class), any(Coordinates.class));

    After refactoring you'll find out whether your mock is still needed or you accidentally introduced an extra call for this method.

  2. yes... in the above case it might be overkill as they are always called of course. But if you conditionally use services you are completely right and your remark is more than valid.