Gmock is a mocking framework for Groovy focused on test readability and conciseness
Spend more time writing code and less writing test
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.
Gmock support Java strong typing and make it perfectly suitable to test an full Java project.
The current version is gmock-0.8.0 and is already packed with tons of feature.
Checkout our documentation to get the full picture and visit our roadmap to see what's coming next.
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
}
}