|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.rhq.test.JMockTest
public class JMockTest
This class can either be used as a base class for tests using JMock or it also can be used as a TestNG listener to provide the JMock context to test classes that need to inherit from another class.
In the former case, the JMock context is accessible through the context protected
field, while in the latter case (when JMockTest is specified as a listener
of a test class), the JMock context is accessible using the getCurrentMockContext()
static method.
Unlike the default behavior of the Listeners annotation which makes the supplied classes the listeners on ALL test methods in ALL classes, this implementation behaves differntly. It checks whether the Listeners annotation is specified on the class that the current test method is being executed on (or its superclasses) and only if it does, the test method is "augmented". This means that the classes can specify if they want to be augmented by JMockTest by specifying it as their listener.
| Field Summary | |
|---|---|
protected org.jmock.Mockery |
context
|
| Constructor Summary | |
|---|---|
JMockTest()
|
|
| Method Summary | |
|---|---|
void |
afterInvocation(org.testng.IInvokedMethod method,
org.testng.ITestResult testResult)
Runs tearDownAfterTest(ITestResult). |
void |
beforeInvocation(org.testng.IInvokedMethod method,
org.testng.ITestResult testResult)
Runs #initBeforeTest(ITestResult). |
static org.jmock.Mockery |
getCurrentMockContext()
|
protected void |
initBeforeTest(Object testObject,
Method testMethod)
Does whatever needs done before the test is invoked. |
void |
initMockContext(Method testMethod)
|
void |
run(org.testng.IHookCallBack iHookCallBack,
org.testng.ITestResult iTestResult)
This method runs #initBeforeTest(ITestResult), followed by the actual test,
followed by tearDownAfterTest(ITestResult). |
protected void |
tearDownAfterTest(org.testng.ITestResult result)
Does whatever needs done after the test has been invoked. |
void |
tearDownMockContext(org.testng.ITestResult testResult)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected org.jmock.Mockery context
| Constructor Detail |
|---|
public JMockTest()
| Method Detail |
|---|
public static org.jmock.Mockery getCurrentMockContext()
public final void initMockContext(Method testMethod)
public final void tearDownMockContext(org.testng.ITestResult testResult)
public final void run(org.testng.IHookCallBack iHookCallBack,
org.testng.ITestResult iTestResult)
#initBeforeTest(ITestResult), followed by the actual test,
followed by tearDownAfterTest(ITestResult).
If you want to modify the behavior of this method, override the above mentioned methods.
run in interface org.testng.IHookableIHookable.run(IHookCallBack, ITestResult)
public final void beforeInvocation(org.testng.IInvokedMethod method,
org.testng.ITestResult testResult)
#initBeforeTest(ITestResult).
beforeInvocation in interface org.testng.IInvokedMethodListenerIInvokedMethodListener.beforeInvocation(IInvokedMethod, ITestResult)
public final void afterInvocation(org.testng.IInvokedMethod method,
org.testng.ITestResult testResult)
tearDownAfterTest(ITestResult).
afterInvocation in interface org.testng.IInvokedMethodListenerIInvokedMethodListener.afterInvocation(IInvokedMethod, ITestResult)
protected void initBeforeTest(Object testObject,
Method testMethod)
If you override this method, be sure to call this method before
your code so that you gain access to the context.
testResult - protected void tearDownAfterTest(org.testng.ITestResult result)
This method calls Mockery.assertIsSatisfied() and nulls out the context.
If you override this method, call this implmentation as the last call in your code.
result -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||