@Sql

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

Java
@Test
@Sql({"/test-schema.sql", "/test-user-data.sql"}) [id="CO1-1"][id="CO1-1"][id="CO1-1"](1)
void userTest() {
	// run code that relies on the test schema and test data
}
<1>  为此测试运行两个脚本。
Kotlin
@Test
@Sql("/test-schema.sql", "/test-user-data.sql") [id="CO2-1"][id="CO1-2"][id="CO2-1"](1)
fun userTest() {
	// run code that relies on the test schema and test data
}
<1>  为此测试运行两个脚本。

有关更多详细信息,请参阅 使用 @Sql 声明性地执行 SQL 脚本