net.sourceforge.xconf.toolbox.mockcontrol
Class MockTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by net.sourceforge.xconf.toolbox.mockcontrol.MockTestCase
All Implemented Interfaces:
junit.framework.Test

public abstract class MockTestCase
extends junit.framework.TestCase

A convenient base class for JUnit tests that require mock objects. This class wraps a MockObjectFactory instance and allows you to easily keep track of MockControls for mock objects without needing to create a test variable for each control.

Author:
Tom Czarniecki
See Also:
MockObjectFactory

Constructor Summary
MockTestCase()
          JUnit TestCase constructor.
MockTestCase(String name)
          JUnit TestCase constructor.
 
Method Summary
 void clear()
          Clear all created MockControls and mock objects.
 org.easymock.MockControl control(Object mockObject)
          Returns the MockControl instance associated with the given mock object.
 Object createMock(Class clazz)
          Creates a default mock object for the given class.
 Object createNiceMock(Class clazz)
          Creates a nice mock object for the given class.
 Object createStrictMock(Class clazz)
          Creates a strict mock object for the given class.
 void replay()
          Invokes replay() on all MockControls created by this test.
 void reset()
          Invokes reset() on all MockControls created by this test.
 void verify()
          Invokes verify() on all MockControls created by this test.
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runBare, runTest, setName, setUp, tearDown, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, failNotEquals, failNotSame, failSame, format
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MockTestCase

public MockTestCase()
JUnit TestCase constructor.


MockTestCase

public MockTestCase(String name)
JUnit TestCase constructor.

Method Detail

createMock

public Object createMock(Class clazz)
Creates a default mock object for the given class. You can retrieve the MockControl for this mock object by passing the returned object to the control(Object) method.

See Also:
MockObjectFactory.createMock(Class)

createNiceMock

public Object createNiceMock(Class clazz)
Creates a nice mock object for the given class. You can retrieve the MockControl for this mock object by passing the returned object to the control(Object) method.

See Also:
MockObjectFactory.createNiceMock(Class)

createStrictMock

public Object createStrictMock(Class clazz)
Creates a strict mock object for the given class. You can retrieve the MockControl for this mock object by passing the returned object to the control(Object) method.

See Also:
MockObjectFactory.createStrictMock(Class)

control

public org.easymock.MockControl control(Object mockObject)
Returns the MockControl instance associated with the given mock object. This mock object must have been created by one of the mock object creation methods above.

See Also:
MockObjectFactory.control(Object)

reset

public void reset()
Invokes reset() on all MockControls created by this test.

See Also:
MockObjectFactory.reset()

replay

public void replay()
Invokes replay() on all MockControls created by this test.

See Also:
MockObjectFactory.replay()

verify

public void verify()
Invokes verify() on all MockControls created by this test.

See Also:
MockObjectFactory.verify()

clear

public void clear()
Clear all created MockControls and mock objects.

See Also:
MockObjectFactory.clear()


Copyright © 2007 Thomas Czarniecki. All Rights Reserved.