public class JMockTest extends Object implements org.testng.IHookable, org.testng.IInvokedMethodListener
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.
| Modifier and Type | Field and Description |
|---|---|
protected org.jmock.Mockery |
context |
| Constructor and Description |
|---|
JMockTest() |
| Modifier and Type | Method and Description |
|---|---|
void |
afterInvocation(org.testng.IInvokedMethod method,
org.testng.ITestResult testResult)
|
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) |
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)
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 - Copyright © 2008-2013 Red Hat, Inc.. All Rights Reserved.