@Sql

@Sql 用于注释测试类或测试方法,以便配置 SQL 脚本,以便在集成测试期间针对给定数据库运行。以下示例展示了如何使用它:

@Sql is used to annotate a test class or test method to configure SQL scripts to be run against a given database during integration tests. The following example shows how to use it:

Java
@Test
@Sql({"/test-schema.sql", "/test-user-data.sql"}) (1)
void userTest() {
	// run code that relies on the test schema and test data
}
1 Run two scripts for this test.
Kotlin
@Test
@Sql("/test-schema.sql", "/test-user-data.sql") (1)
fun userTest() {
	// run code that relies on the test schema and test data
}
2 Run two scripts for this test.

有关进一步的详细信息,请参见 Executing SQL scripts declaratively with @Sql