@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 指令碼。