类 SqlScriptsTestExecutionListener

java.lang.Object
cn.taketoday.test.context.support.AbstractTestExecutionListener
cn.taketoday.test.context.jdbc.SqlScriptsTestExecutionListener
所有已实现的接口:
cn.taketoday.core.Ordered, AotTestExecutionListener, TestExecutionListener

public class SqlScriptsTestExecutionListener extends AbstractTestExecutionListener implements AotTestExecutionListener
TestExecutionListener that provides support for executing SQL scripts and inlined statements configured via the @Sql annotation.

Class-level annotations that are constrained to a class-level execution phase (BEFORE_TEST_CLASS or AFTER_TEST_CLASS) will be run once before all test methods or once after all test methods, respectively. All other scripts and inlined statements will be executed before or after execution of the corresponding test method, depending on the configured value of the executionPhase flag.

Scripts and inlined statements will be executed without a transaction, within an existing Infra-managed transaction, or within an isolated transaction, depending on the configured value of SqlConfig.transactionMode() and the presence of a transaction manager.

Script Resources

For details on default script detection and how script resource locations are interpreted, see Sql.scripts().

Required Infra Beans

A PlatformTransactionManager and a DataSource, just a PlatformTransactionManager, or just a DataSource must be defined as beans in the Infra ApplicationContext for the corresponding test. Consult the javadocs for SqlConfig.transactionMode(), SqlConfig.transactionManager(), SqlConfig.dataSource(), TestContextTransactionUtils.retrieveDataSource(cn.taketoday.test.context.TestContext, java.lang.String), and TestContextTransactionUtils.retrieveTransactionManager(cn.taketoday.test.context.TestContext, java.lang.String) for details on permissible configuration constellations and on the algorithms used to locate these beans.

Required Dependencies

Use of this listener requires the today-jdbc and today-tx modules as well as their transitive dependencies to be present on the classpath.

从以下版本开始:
4.0
作者:
Sam Brannen, Dmitry Semukhin, Andreas Ahlenstorf, Harry Yang
另请参阅: