|
对于最新稳定版本,请使用 Spring Framework 7.0.6! |
@Sql
@Sql 用于在测试类或测试方法上添加注解,以配置在集成测试期间针对指定数据库执行的 SQL 脚本。以下示例展示了如何使用它:
-
Java
-
Kotlin
@Test
@Sql({"/test-schema.sql", "/test-user-data.sql"}) (1)
void userTest() {
// run code that relies on the test schema and test data
}
| 1 | 为此测试运行两个脚本。 |
@Test
@Sql("/test-schema.sql", "/test-user-data.sql") (1)
fun userTest() {
// run code that relies on the test schema and test data
}
| 1 | 为此测试运行两个脚本。 |
有关更多详情,请参见使用 @Sql 声明式执行 SQL 脚本。