Package 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:
junit.framework.Test
- Direct Known Subclasses:
MockObjectTestCase
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.0
-
Field Summary
Fields inherited from class org.jmock.core.MockObjectSupportTestCase
ANYTHING, NOT_NULL, NULL
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondefaultMockNameForType
(Class mockedType) Calculatesexactly
(int expectedCount) Creates a mock object that mocks the given type.Creates a mock object that mocks the given type and is explicitly given a name.never()
protected DynamicMock
newCoreMock
(Class mockedType, String roleName) once()
onConsecutiveCalls
(Stub[] stubs) onConsecutiveCalls
(Stub stub1, Stub stub2) onConsecutiveCalls
(Stub stub1, Stub stub2, Stub stub3) onConsecutiveCalls
(Stub stub1, Stub stub2, Stub stub3, Stub stub4) returnIterator
(Object[] array) returnIterator
(Collection collection) returnValue
(boolean result) returnValue
(byte result) returnValue
(char result) returnValue
(double result) returnValue
(float result) returnValue
(int result) returnValue
(long result) returnValue
(short result) throwException
(Throwable throwable) Methods inherited from class org.jmock.core.MockObjectSupportTestCase
and, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, arrayContaining, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, assertThat, collectionContaining, collectionContaining, compatibleType, contains, endsWith, eq, eq, eq, eq, eq, eq, eq, eq, eq, eq, hasProperty, hasProperty, isA, isIn, isIn, mapContaining, mapContaining, mapWithKey, mapWithKey, mapWithValue, mapWithValue, not, or, same, startsWith, stringContains, toString
Methods inherited from class org.jmock.core.VerifyingTestCase
registerToVerify, runBare, unregisterToVerify, verify
Methods inherited from class junit.framework.TestCase
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, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, tearDown, toString
-
Constructor Details
-
MockObjectTestCase
public MockObjectTestCase() -
MockObjectTestCase
-
-
Method Details
-
mock
Creates a mock object that mocks the given type. The mock object is named after the type; the exact name is calculated bydefaultMockNameForType(java.lang.Class)
.- Parameters:
mockedType
- The type to be mocked.- Returns:
- A
Mock
object that mocks mockedType.
-
mock
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 bydefaultMockNameForType(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
-
newDummy
- Overrides:
newDummy
in classMockObjectSupportTestCase
-
newDummy
- Overrides:
newDummy
in classMockObjectSupportTestCase
-
newDummy
- Overrides:
newDummy
in classMockObjectSupportTestCase
-
defaultMockNameForType
Calculates- Parameters:
mockedType
-- Returns:
- mock name
-
returnValue
-
returnValue
-
returnValue
-
returnValue
-
returnValue
-
returnValue
-
returnValue
-
returnValue
-
returnValue
-
returnIterator
-
returnIterator
-
throwException
-
once
-
atLeastOnce
-
atMostOnce
-
exactly
-
never
-
never
-
onConsecutiveCalls
- Since:
- 1.0.1
-
onConsecutiveCalls
- Since:
- 1.0.1
-
onConsecutiveCalls
- Since:
- 1.0.1
-
onConsecutiveCalls
- Since:
- 1.1.0
-
doAll
- Since:
- 1.1.0
-
doAll
- Since:
- 1.1.0
-
doAll
- Since:
- 1.1.0
-
doAll
- Since:
- 1.1.0
-