public abstract class MockObjectTestCase extends VerifyingTestCase
TestCase that supports testing with mock objects.
It wraps a Mockery and automatically asserts that
all expectations have been met at the end of the test before
TestCase.tearDown() is called.| Constructor and Description |
|---|
MockObjectTestCase() |
MockObjectTestCase(java.lang.String name) |
| Modifier and Type | Method and Description |
|---|---|
void |
checking(org.jmock.internal.ExpectationBuilder expectations)
Specify expectations upon the mock objects in the test.
|
<T> T |
mock(java.lang.Class<T> typeToMock)
Create a mock object of type T with a name derived from its type.
|
<T> T |
mock(java.lang.Class<T> typeToMock,
java.lang.String name)
Create a mock object of type T with an explicit name.
|
Sequence |
sequence(java.lang.String name)
Returns a new sequence that is used to constrain the order in which
expectations can occur.
|
void |
setDefaultResultForType(java.lang.Class<?> type,
java.lang.Object result)
Sets the result returned for the given type when no return value has been explicitly
specified in the expectation.
|
void |
setImposteriser(Imposteriser imposteriser)
Changes the imposteriser used to adapt mock objects to the mocked type.
|
void |
setNamingScheme(MockObjectNamingScheme namingScheme)
Changes the naming scheme used to generate names for mock objects that
have not been explicitly named in the test.
|
States |
states(java.lang.String name)
Returns a new state machine that is used to constrain the order in which
expectations can occur.
|
addVerifier, runBare, verifycountTestCases, createResult, getName, run, run, runTest, setName, setUp, tearDown, toStringassertEquals, 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, formatpublic MockObjectTestCase()
public MockObjectTestCase(java.lang.String name)
public void setDefaultResultForType(java.lang.Class<?> type,
java.lang.Object result)
type - The type for which to return result.result - The value to return when a method of return type type
is invoked for which an explicit return value has has not been specified.public void setImposteriser(Imposteriser imposteriser)
public void setNamingScheme(MockObjectNamingScheme namingScheme)
public void checking(org.jmock.internal.ExpectationBuilder expectations)
public <T> T mock(java.lang.Class<T> typeToMock,
java.lang.String name)
typeToMock - The type to be mockedname - The name of the new mock object that is used to identify the mock object
in error messagespublic <T> T mock(java.lang.Class<T> typeToMock)
typeToMock - The type to be mockedpublic Sequence sequence(java.lang.String name)
name - The name of the sequence.public States states(java.lang.String name)
name - The name of the state machine.