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

Version 1 Next »

Suppose we are trying to test the following application:

We might be tempted to replace logger and factory with Groovy's built-in mocks, but it turns out that Maps or Expandos are often sufficiently powerful enough in Groovy that we don't need full blown dynamic mocks.

Instead of a mock for logger, we can use an Expando as follows:

Insread of a mock for factory, we can use a simple map as follows:

Here, myObj is the object we want the factory to return.

Putting this altogether yields te following complete test:

  • No labels