|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.testng.Assert
com.javaforge.tapestry.testng.TestBase
public class TestBase
A base class for creating TestNG unit tests for Tapestry 4 applications. With slightly more effort, this may be used as a utility class with other frameworks, such as JUnit.
A single strict mock control is used for all mocks, which means that order of operations is checked not just for any single mock but across mocks.
Provides common mock factory and mock trainer methods.
Provides easy access to instantiated component instances.
Extends from Assert to bring in all the public static assert methods without
requiring extra imports.
TestNG supports running tests in parallel, as does this class. The EasyMock control is stored in a thread local. This is necessary as TestNG instantiates a single instance of the test case class, and invokes methods on it from multiple threads.
| Constructor Summary | |
|---|---|
TestBase()
|
|
| Method Summary | ||
|---|---|---|
void |
cleanupControlSource()
Discards any mock objects created during the test. |
|
org.easymock.IMocksControl |
getMocksControl()
Returns the control object used for all mocks created by this test case. |
|
|
newInstance(java.lang.Class<T> componentClass,
java.lang.Object... properties)
Creates a new instance of the provided class using the Creator utility. |
|
org.apache.tapestry.IMarkupWriter |
newMarkupWriter()
Mock factory method. |
|
|
newMock(java.lang.Class<T> mockClass)
Creates a new mock object of the indicated type. |
|
org.apache.tapestry.IRequestCycle |
newRequestCycle()
Mock factory method. |
|
void |
replay()
Replay's the mocks control, preparing all mocks for testing. |
|
|
setReturnValue(T returnValue)
Sets the return value for the most recent method call upon the mock. |
|
void |
setThrowable(java.lang.Throwable throwable)
Trains a mock object to throw an exception. |
|
void |
unreachable()
Invoked to indicate code should not reach a point. |
|
void |
verify()
Verifies the mocks control, ensuring that all mocks completed all trained method invocations, then resets the control to allow more training of the mocks. |
|
| 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, 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 |
|---|
public final <T> T newInstance(java.lang.Class<T> componentClass,
java.lang.Object... properties)
Creator utility.
T - the component typecomponentClass - properties - alternating property names and property values to be injected into the instance
public final void cleanupControlSource()
public final <T> T newMock(java.lang.Class<T> mockClass)
replay() and verify()).
T - the type of the mock objectmockClass - the class to mock
public final void replay()
public final void verify()
public final org.easymock.IMocksControl getMocksControl()
public final <T> void setReturnValue(T returnValue)
returnValue - value to be returned from the method callpublic final void setThrowable(java.lang.Throwable throwable)
throwable - the exception to be thrown by the most recent method call on the mockpublic final void unreachable()
public final org.apache.tapestry.IRequestCycle newRequestCycle()
public final org.apache.tapestry.IMarkupWriter newMarkupWriter()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||