GMock

GMock is a mocking framework for the Groovy language.

GMock is all about simple syntax and readability of your tests so you spend less time learning the framework and more writing code. To use GMock just drop the gmock jar file in your classpath.

Getting Started

First extend the org.gmock.GMockTestCase. Create mock object using the mock() method. You setup expectation simply by calling method on your mock.

def mockLoader = mock()
mockLoader.load("fruit").returns("apple")

The code you are testing should be executed within the play closure.

void testBasic(){
  // create mock and setup expectation
  play {
    // run your code
  }
}

In a nutshell

Visit the website for a full documentation: GMock