|
Project Information
Members
Featured
Downloads
Wiki pages
Links
|
GmockGmock 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. The current version is gmock-0.8.2 and is packed with tons of feature. Checkout the full documentation to get the full picture. News
Getting StartedFirst 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
Here is a full example: import org.gmock.GMockTestCase
class LoaderTest extends GMockTestCase {
void testLoader(){
def mockLoader = mock()
mockLoader.load('key').returns('value')
play {
assertEquals "value", mockLoader.load('key')
}
}
}
|