@TestExecutionListeners(value={ServletTestExecutionListener.class,DirtiesContextBeforeModesTestExecutionListener.class,DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class}) public abstract class AbstractTestNGSpringContextTests extends Object implements org.testng.IHookable, ApplicationContextAware
ApplicationContext testing support in a TestNG
 environment.
 Concrete subclasses:
@ContextConfiguration annotation to configure the application context resource locations
 or annotated classes. If your test
 does not need to load an application context, you may choose to omit the
 @ContextConfiguration declaration and to
 configure the appropriate
 TestExecutionListeners
 manually.super();.The following TestExecutionListeners are configured by default:
 
ContextConfiguration, 
TestContext, 
TestContextManager, 
TestExecutionListeners, 
ServletTestExecutionListener, 
DirtiesContextBeforeModesTestExecutionListener, 
DependencyInjectionTestExecutionListener, 
DirtiesContextTestExecutionListener, 
AbstractTransactionalTestNGSpringContextTests, 
AbstractJUnit4SpringContextTests| Modifier and Type | Field and Description | 
|---|---|
protected ApplicationContext | 
applicationContext
The  
ApplicationContext that was injected into this test instance
 via setApplicationContext(ApplicationContext). | 
protected Log | 
logger
Logger available to subclasses 
 | 
| Constructor and Description | 
|---|
AbstractTestNGSpringContextTests()
Construct a new AbstractTestNGSpringContextTests instance and initialize
 the internal  
TestContextManager for the current test. | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
run(org.testng.IHookCallBack callBack,
   org.testng.ITestResult testResult)
Delegates to the  
test
 method in the supplied callback to execute the actual test
 and then tracks the exception thrown during test execution, if any. | 
void | 
setApplicationContext(ApplicationContext applicationContext)
Set the  
ApplicationContext to be used by this test instance,
 provided via ApplicationContextAware semantics. | 
protected void | 
springTestContextAfterTestClass()
Delegates to the configured  
TestContextManager to call
 'after test class' callbacks. | 
protected void | 
springTestContextAfterTestMethod(Method testMethod)
Delegates to the configured  
TestContextManager to
 post-process the test method after the actual test has executed. | 
protected void | 
springTestContextBeforeTestClass()
Delegates to the configured  
TestContextManager to call
 'before test class'
 callbacks. | 
protected void | 
springTestContextBeforeTestMethod(Method testMethod)
Delegates to the configured  
TestContextManager to
 pre-process
 the test method before the actual test is executed. | 
protected void | 
springTestContextPrepareTestInstance()
Delegates to the configured  
TestContextManager to
 prepare this test
 instance prior to execution of any individual tests, for example for
 injecting dependencies, etc. | 
protected final Log logger
protected ApplicationContext applicationContext
ApplicationContext that was injected into this test instance
 via setApplicationContext(ApplicationContext).public AbstractTestNGSpringContextTests()
TestContextManager for the current test.public final void setApplicationContext(ApplicationContext applicationContext)
ApplicationContext to be used by this test instance,
 provided via ApplicationContextAware semantics.setApplicationContext in interface ApplicationContextAwareapplicationContext - the ApplicationContext that this test runs inBeanInitializationExceptionprotected void springTestContextBeforeTestClass()
                                         throws Exception
TestContextManager to call
 'before test class'
 callbacks.Exception - if a registered TestExecutionListener throws an
 exceptionprotected void springTestContextPrepareTestInstance()
                                             throws Exception
TestContextManager to
 prepare this test
 instance prior to execution of any individual tests, for example for
 injecting dependencies, etc.Exception - if a registered TestExecutionListener throws an
 exceptionprotected void springTestContextBeforeTestMethod(Method testMethod) throws Exception
TestContextManager to
 pre-process
 the test method before the actual test is executed.testMethod - the test method which is about to be executed.Exception - allows all exceptions to propagate.public void run(org.testng.IHookCallBack callBack,
                org.testng.ITestResult testResult)
test
 method in the supplied callback to execute the actual test
 and then tracks the exception thrown during test execution, if any.run in interface org.testng.IHookableIHookable.run(org.testng.IHookCallBack,
 org.testng.ITestResult)protected void springTestContextAfterTestMethod(Method testMethod) throws Exception
TestContextManager to
 post-process the test method after the actual test has executed.testMethod - the test method which has just been executed on the
 test instanceException - allows all exceptions to propagateprotected void springTestContextAfterTestClass()
                                        throws Exception
TestContextManager to call
 'after test class' callbacks.Exception - if a registered TestExecutionListener throws an
 exception