此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Framework 6.2.0! |
@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 脚本。