|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.testng.Assert org.apache.tapestry5.ioc.test.TestUtils org.apache.tapestry5.ioc.test.TestBase
public class TestBase
Manages a set of EasyMock mock objects. Used as a base class for test cases.
Extends fromAssert
to bring in all the public static assert methods without requiring extra
imports.
Provides a common mock factory method, newMock(Class)
. A single standard mock control is used for
all mock objects. Standard mocks do not care about the exact order in which methods are invoked, though they are as
rigorous as strict mocks when checking that parameters are the correct values.
This base class is created with the intention of use within a TestNG test suite; if using JUnit, you can get the same
functionality using MockTester
.
This class is thread safe (it uses a thread local to store the mock control). In theory, this should allow TestNG to
execute tests in parallel.
This class was originally in the tapestry-ioc module as was moved to tapestry-test; the package name was not changed to ensure backwards compatibility.
EasyMock.createControl()
,
MockTester
Constructor Summary | |
---|---|
TestBase()
|
Method Summary | ||
---|---|---|
void |
discardMockControl()
Discards any mock objects created during the test. |
|
protected static
|
expect(T value)
Convenience for EasyMock.expect(Object) . |
|
protected org.easymock.IMocksControl |
getMocksControl()
|
|
protected static
|
newCapture()
A factory method to create EasyMock Capture objects. |
|
protected
|
newMock(Class<T> mockClass)
Creates a new mock object of the indicated type. |
|
protected void |
replay()
Switches each mock object created by newMock(Class) into replay mode (out of the initial training
mode). |
|
protected static void |
setAnswer(org.easymock.IAnswer<?> answer)
Convienience for EasyMock.expectLastCall() with
IExpectationSetters.andAnswer(org.easymock.IAnswer) . |
|
protected static void |
setThrowable(Throwable throwable)
Convienience for EasyMock.expectLastCall() with IExpectationSetters.andThrow(Throwable) . |
|
protected void |
verify()
Verifies that all trained methods have been invoked on all mock objects (created by newMock(Class) , then
switches each mock object back to training mode. |
Methods inherited from class org.apache.tapestry5.ioc.test.TestUtils |
---|
assertArraysEqual, assertListsEquals, assertListsEquals, assertMessageContains, create, get, set, showLists, unreachable |
Methods inherited from class org.testng.Assert |
---|
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEqualsNoOrder, assertEqualsNoOrder, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail, fail |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public TestBase()
Method Detail |
---|
protected final org.easymock.IMocksControl getMocksControl()
IMocksControl
for this thread.public final void discardMockControl()
protected final <T> T newMock(Class<T> mockClass)
T
- the type of the mock objectmockClass
- the class to mock
protected final void replay()
newMock(Class)
into replay mode (out of the initial training
mode).
protected final void verify()
newMock(Class)
, then
switches each mock object back to training mode.
protected static void setThrowable(Throwable throwable)
EasyMock.expectLastCall()
with IExpectationSetters.andThrow(Throwable)
.
throwable
- the exception to be thrown by the most recent method call on any mockprotected static void setAnswer(org.easymock.IAnswer<?> answer)
EasyMock.expectLastCall()
with
IExpectationSetters.andAnswer(org.easymock.IAnswer)
.
answer
- callback for the most recent method invocationprotected static <T> org.easymock.IExpectationSetters<T> expect(T value)
EasyMock.expect(Object)
.
value
- to expect
protected static <T> org.easymock.Capture<T> newCapture()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |