Siddhu is a London-based software engineer who was once described by somebody he annoyed as the epitome of clubbable brown gentlemanliness.

Matching Functions as arguments and varags using Mockito and Scala

Wednesday, September 17, 2014

Having spent all morning fighting through the vagaries of mocking and verifying methods that take functions as arguments and variable arguments using Scala and Mockito, I thought I'd scribble this down (mostly for myself, as I'll probably hit this selfsame problem again at some point in the future).

The Problem

Let us assume you have a class FooService, which has a method, quite unimaginatively called getBar that takes a function (Int, Int) => Int and a variable number of additional arguments.