spring-framework / org.springframework.test.context.testng / AbstractTestNGSpringContextTests

AbstractTestNGSpringContextTests

@TestExecutionListeners([ServletTestExecutionListener, DirtiesContextBeforeModesTestExecutionListener, DependencyInjectionTestExecutionListener, DirtiesContextTestExecutionListener]) abstract class AbstractTestNGSpringContextTests : IHookable, ApplicationContextAware

Abstract base test class which integrates the Spring TestContext Framework with explicit ApplicationContext testing support in a TestNG environment.

Concrete subclasses:

The following org.springframework.test.context.TestExecutionListener are configured by default:

Author
Sam Brannen

Author
Juergen Hoeller

Since
2.5

See Also
ContextConfigurationTestContextTestContextManagerTestExecutionListenersServletTestExecutionListenerDirtiesContextBeforeModesTestExecutionListenerDependencyInjectionTestExecutionListenerDirtiesContextTestExecutionListenerAbstractTransactionalTestNGSpringContextTestsorg.springframework.test.context.junit4.AbstractJUnit4SpringContextTests

Constructors

<init>

AbstractTestNGSpringContextTests()

Construct a new AbstractTestNGSpringContextTests instance and initialize the internal TestContextManager for the current test class.

Functions

run

open fun run(callBack: IHookCallBack, testResult: ITestResult): Unit

Delegates to the test in the supplied callback to execute the actual test and then tracks the exception thrown during test execution, if any.

setApplicationContext

fun setApplicationContext(applicationContext: ApplicationContext): Unit

Set the ApplicationContext to be used by this test instance, provided via ApplicationContextAware semantics.

Inheritors

AbstractTransactionalTestNGSpringContextTests

abstract class AbstractTransactionalTestNGSpringContextTests : AbstractTestNGSpringContextTests

Abstract Transactional extension of AbstractTestNGSpringContextTests which adds convenience functionality for JDBC access. Expects a DataSource bean and a PlatformTransactionManager bean to be defined in the Spring ApplicationContext.

This class exposes a JdbcTemplate and provides an easy way to count the number of rows in a table (potentially with a WHERE clause), delete from tables, drop tables, and execute SQL scripts within a transaction.

Concrete subclasses must fulfill the same requirements outlined in AbstractTestNGSpringContextTests.

The following org.springframework.test.context.TestExecutionListener are configured by default:

  • org.springframework.test.context.web.ServletTestExecutionListener
  • org.springframework.test.context.support.DependencyInjectionTestExecutionListener
  • org.springframework.test.context.support.DirtiesContextTestExecutionListener
  • org.springframework.test.context.transaction.TransactionalTestExecutionListener
  • org.springframework.test.context.jdbc.SqlScriptsTestExecutionListener