Suppose we have the following Java interface (and we are only using interfaces because we want to demonstrate using Groovy to test Java using Mocks later):
Now suppose we have an implementation method as follows:
For numbers, the reverse() method will negate them. Thanks to duck-typing, other objects that we try to reverse will just call their respective types reverse() method if it exists, e.g. so it will work for String and List objects.
Now suppose we make use of a reverser in some code we are trying to test.
Labels