org.jmock
Class MockObjectTestCase
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.jmock.core.VerifyingTestCase
org.jmock.core.MockObjectSupportTestCase
org.jmock.MockObjectTestCase
- All Implemented Interfaces:
- Test
- Direct Known Subclasses:
- MockObjectTestCase
public abstract class MockObjectTestCase
- extends MockObjectSupportTestCase
A base class for tests that use Mock Objects.
This class provides methods for creating mock objects and expectations and automatically
verifying mock objects after the test has run but before the test fixture has been torn down.
- Since:
- 1.0
Methods inherited from class org.jmock.core.MockObjectSupportTestCase |
and, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, contains, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, hasProperty, hasProperty, isA, newDummy, newDummy, newDummy, not, or, same, stringContains |
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 |
MockObjectTestCase
public MockObjectTestCase()
MockObjectTestCase
public MockObjectTestCase(String name)
mock
public Mock mock(Class mockedType)
- Creates a mock object that mocks the given type. The mock object is named after the type; the exact
name is calculated by
defaultMockNameForType(java.lang.Class)
.
- Parameters:
mockedType
- The type to be mocked.
- Returns:
- A
Mock
object that mocks mockedType.
mock
public Mock mock(Class mockedType,
String roleName)
- Creates a mock object that mocks the given type and is explicitly given a name.
The mock object is named after the type; the exact name is calculated by
defaultMockNameForType(java.lang.Class)
.
- Parameters:
mockedType
- The type to be mocked.roleName
- The name of the mock object
- Returns:
- A
Mock
object that mocks mockedType.
newCoreMock
protected DynamicMock newCoreMock(Class mockedType,
String roleName)
defaultMockNameForType
public String defaultMockNameForType(Class mockedType)
- Calculates
- Parameters:
mockedType
-
- Returns:
returnValue
public Stub returnValue(Object o)
returnValue
public Stub returnValue(boolean result)
returnValue
public Stub returnValue(byte result)
returnValue
public Stub returnValue(char result)
returnValue
public Stub returnValue(short result)
returnValue
public Stub returnValue(int result)
returnValue
public Stub returnValue(long result)
returnValue
public Stub returnValue(float result)
returnValue
public Stub returnValue(double result)
returnIterator
public Stub returnIterator(Collection collection)
returnIterator
public Stub returnIterator(Object[] array)
throwException
public Stub throwException(Throwable throwable)
once
public InvocationMatcher once()
atLeastOnce
public InvocationMatcher atLeastOnce()
exactly
public InvocationMatcher exactly(int expectedCount)
never
public InvocationMatcher never()
never
public InvocationMatcher never(String errorMessage)
onConsecutiveCalls
public Stub onConsecutiveCalls(Stub stub1,
Stub stub2)
onConsecutiveCalls
public Stub onConsecutiveCalls(Stub stub1,
Stub stub2,
Stub stub3)
onConsecutiveCalls
public Stub onConsecutiveCalls(Stub stub1,
Stub stub2,
Stub stub3,
Stub stub4)