Skip to content
Skip to breadcrumbs
Skip to header menu
Skip to action menu
Skip to quick search
Quick Search
Browse
Pages
Blog
Labels
Attachments
Mail
Advanced
What’s New
Space Directory
Feed Builder
Keyboard Shortcuts
Confluence Gadgets
Log In
Sign Up
Dashboard
Groovy
Copy Page
You are not logged in. Any changes you make will be marked as
anonymous
. You may want to
Log In
if you already have an account. You can also
Sign Up
for a new account.
This page is being edited by
.
Paragraph
Paragraph
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Preformatted
Quote
Bold
Italic
Underline
More colours
Strikethrough
Subscript
Superscript
Monospace
Clear Formatting
Bullet list
Numbered list
Outdent
Indent
Align left
Align center
Align right
Link
Table
Insert
Insert Content
Image
Link
Attachment
Symbol
Emoticon
Wiki Markup
Horizontal rule
tinymce.confluence.insert_menu.macro_desc
Info
JIRA Issue
Status
Gallery
Tasklist
Table of Contents
Other Macros
Page Layout
No Layout
Two column (simple)
Two column (simple, left sidebar)
Two column (simple, right sidebar)
Three column (simple)
Two column
Two column (left sidebar)
Two column (right sidebar)
Three column
Three column (left and right sidebars)
Undo
Redo
Find/Replace
Keyboard Shortcuts Help
<p><a href="http://rmock.sourceforge.net/">RMock</a> is a Java mock object framework typically used with JUnit 3.x. RMock has support for a setup-modify-run-verify workflow when writing JUnit tests. It integrates better with IDE refactoring support than some other popular mocking frameworks and allows designing classes and interfaces in a true test-first fashion.</p> <p>The sections below illustrate using RMock for the mocking parts of <a class="confluence-link" href="/display/GROOVY/Using+Testing+Frameworks+with+Groovy" data-linked-resource-id="67695" data-linked-resource-type="page" data-linked-resource-default-alias="Using Testing Frameworks with Groovy" data-base-url="http://docs.codehaus.org">Using Testing Frameworks with Groovy</a>.</p> <h2>The Item Storer Example</h2> <p>We are going to consider how you might use RMock as part of testing the <a class="confluence-link" href="/display/GROOVY/Using+Testing+Frameworks+with+Groovy#UsingTestingFrameworkswithGroovy-AnItemStorerExample" data-anchor="AnItemStorerExample" data-linked-resource-id="67695" data-linked-resource-type="page" data-linked-resource-default-alias="Using Testing Frameworks with Groovy#AnItemStorerExample" data-base-url="http://docs.codehaus.org">Item Storer Example</a>.</p> <p>Here is how we can test <code>JavaStorer</code>:</p> <table class="wysiwyg-macro" data-macro-name="code" style="background-image: url(/plugins/servlet/confluence/placeholder/macro-heading?definition=e2NvZGV9&locale=en_GB&version=2); background-repeat: no-repeat;" data-macro-body-type="PLAIN_TEXT"><tr><td class="wysiwyg-macro-body"><pre> // require(groupId:'com.agical.rmock', artifactId:'rmock', version='2.0.2') // require(groupId:'junit', artifactId:'junit', version='3.8.2') // require(groupId:'cglib', artifactId:'cglib-nodep', version='2.2_beta1') import com.agical.rmock.extension.junit.RMockTestCase class RmockTest extends RMockTestCase { def mockReverser, storer protected void setUp() throws Exception { mockReverser = mock(Reverser.class, 'mockReverser') storer = new JavaStorer(mockReverser) } void testStorage() { expectReverse(123.456, -123.456) expectReverse('hello', 'olleh') startVerification() checkReverse(123.456, -123.456) checkReverse('hello', 'olleh') } def expectReverse(input, output) { mockReverser.reverse(input) modify().returnValue(output) } def checkReverse(value, reverseValue) { storer.put(value) assert value == storer.get() assert reverseValue == storer.getReverse() } } def suite = new junit.framework.TestSuite() suite.addTestSuite(RmockTest.class) junit.textui.TestRunner.run(suite) </pre></td></tr></table>
Please type the word appearing in the picture.
Attachments
Labels
Location
Watch this page
< Edit
Preview >
Loading…
Save
Cancel
Next hint
search
attachments
weblink
advanced