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

Package org.springframework.test.context.testng

Types

AbstractTestNGSpringContextTests

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:

  • Typically declare a class-level ContextConfiguration annotation to configure the ApplicationContext 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 org.springframework.test.context.TestExecutionListener manually.
  • Must have constructors which either implicitly or explicitly delegate to super();.

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

  • org.springframework.test.context.web.ServletTestExecutionListener
  • org.springframework.test.context.support.DirtiesContextBeforeModesTestExecutionListener
  • org.springframework.test.context.support.DependencyInjectionTestExecutionListener
  • org.springframework.test.context.support.DirtiesContextTestExecutionListener

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