Class MockObjectTestCase
java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.jmock.integration.junit3.VerifyingTestCase
org.jmock.integration.junit3.MockObjectTestCase
- All Implemented Interfaces:
junit.framework.Test
- Direct Known Subclasses:
AnnouncerTests, AuctionSniperTests, DJTests, GettingStartedJUnit3, GettingStartedJUnit3Mockomatic
A
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.-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidchecking(ExpectationBuilder expectations) Specify expectations upon the mock objects in the test.context()private void<T> TCreate a mock object of type T with a name derived from its type.<T> TCreate a mock object of type T with an explicit name.Returns a new sequence that is used to constrain the order in which expectations can occur.voidsetDefaultResultForType(Class<?> type, Object result) Sets the result returned for the given type when no return value has been explicitly specified in the expectation.voidsetImposteriser(Imposteriser imposteriser) Changes the imposteriser used to adapt mock objects to the mocked type.voidsetNamingScheme(MockObjectNamingScheme namingScheme) Changes the naming scheme used to generate names for mock objects that have not been explicitly named in the test.Returns a new state machine that is used to constrain the order in which expectations can occur.Methods inherited from class VerifyingTestCase
addVerifier, runBare, verifyMethods 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
-
Field Details
-
context
-
-
Constructor Details
-
MockObjectTestCase
public MockObjectTestCase() -
MockObjectTestCase
-
-
Method Details
-
initialise
private void initialise() -
context
-
setDefaultResultForType
Sets the result returned for the given type when no return value has been explicitly specified in the expectation.- Parameters:
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.
-
setImposteriser
Changes the imposteriser used to adapt mock objects to the mocked type. The default imposteriser allows a test to mock interfaces but not classes, so you'll have to plug a different imposteriser into the Mockery if you want to mock classes. -
setNamingScheme
Changes the naming scheme used to generate names for mock objects that have not been explicitly named in the test. The default naming scheme names mock objects by lower-casing the first letter of the class name, so a mock object of type BananaSplit will be called "bananaSplit" if it is not explicitly named in the test. -
checking
Specify expectations upon the mock objects in the test. -
mock
-
mock
Create a mock object of type T with a name derived from its type.- Parameters:
typeToMock- The type to be mocked- Returns:
- A new mock object of type
-
sequence
-
states
-