Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

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.

  • No labels