@TestExecutionListeners(value={ServletTestExecutionListener.class,DirtiesContextBeforeModesTestExecutionListener.class,DependencyInjectionTestExecutionListener.class,DirtiesContextTestExecutionListener.class,EventPublishingTestExecutionListener.class}) public abstract class AbstractTestNGSpringContextTests extends Object implements org.testng.IHookable, ApplicationContextAware
ApplicationContext testing support in a TestNG
 environment.
 Concrete subclasses should typically declare a class-level
 @ContextConfiguration annotation to
 configure the application context resource locations or component 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. Concrete subclasses must also have
 constructors which either implicitly or explicitly delegate to super();.
 
The following TestExecutionListeners are configured by default:
 
ContextConfiguration, 
TestContext, 
TestContextManager, 
TestExecutionListeners, 
ServletTestExecutionListener, 
DirtiesContextBeforeModesTestExecutionListener, 
DependencyInjectionTestExecutionListener, 
DirtiesContextTestExecutionListener, 
EventPublishingTestExecutionListener, 
AbstractTransactionalTestNGSpringContextTests, 
AbstractJUnit4SpringContextTests| Modifier and Type | Field and Description | 
|---|---|
| protected ApplicationContext | applicationContextThe  ApplicationContextthat was injected into this test instance
 viasetApplicationContext(ApplicationContext). | 
| protected Log | loggerLogger available to subclasses. | 
| Constructor and Description | 
|---|
| AbstractTestNGSpringContextTests()Construct a new  AbstractTestNGSpringContextTestsinstance and initialize
 the internalTestContextManagerfor the current test class. | 
| Modifier and Type | Method and Description | 
|---|---|
| void | run(org.testng.IHookCallBack callBack,
   org.testng.ITestResult testResult)Delegates to the test
 method in the supplied  callbackto execute the actual test
 and then tracks the exception thrown during test execution, if any. | 
| void | setApplicationContext(ApplicationContext applicationContext)Set the  ApplicationContextto be used by this test instance,
 provided viaApplicationContextAwaresemantics. | 
| protected void | springTestContextAfterTestClass()Delegates to the configured  TestContextManagerto call
 'after test class' callbacks. | 
| protected void | springTestContextAfterTestMethod(Method testMethod)Delegates to the configured  TestContextManagerto
 post-process the test method after the actual test has executed. | 
| protected void | springTestContextBeforeTestClass()Delegates to the configured  TestContextManagerto call
 'before test class' callbacks. | 
| protected void | springTestContextBeforeTestMethod(Method testMethod)Delegates to the configured  TestContextManagerto
 pre-process
 the test method before the actual test is executed. | 
| protected void | springTestContextPrepareTestInstance()Delegates to the configured  TestContextManagerto
 prepare this test
 instance prior to execution of any individual tests, for example for
 injecting dependencies, etc. | 
protected final Log logger
@Nullable protected ApplicationContext applicationContext
ApplicationContext that was injected into this test instance
 via setApplicationContext(ApplicationContext).public AbstractTestNGSpringContextTests()
AbstractTestNGSpringContextTests instance and initialize
 the internal TestContextManager for the current test class.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 inBeanInitializationException@BeforeClass(alwaysRun=true)
protected void springTestContextBeforeTestClass()
                                                                      throws Exception
TestContextManager to call
 'before test class' callbacks.Exception - if a registered TestExecutionListener throws an exception@BeforeClass(alwaysRun=true,
             dependsOnMethods="springTestContextBeforeTestClass")
protected 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 exception@BeforeMethod(alwaysRun=true) protected 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 executedException - allows all exceptions to propagatepublic void run(org.testng.IHookCallBack callBack,
                org.testng.ITestResult testResult)
callback to execute the actual test
 and then tracks the exception thrown during test execution, if any.run in interface org.testng.IHookableIHookable.run(IHookCallBack, ITestResult)@AfterMethod(alwaysRun=true) 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 propagate@AfterClass(alwaysRun=true)
protected void springTestContextAfterTestClass()
                                                                    throws Exception
TestContextManager to call
 'after test class' callbacks.Exception - if a registered TestExecutionListener throws an exception