我原来的测试是这样的:
@Test
@SqlGroup(
{
@Sql(
executionPhase = BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = ISOLATED),
scripts = {"classpath:test/sqls/_truncate_tables.sql"}
),
@Sql(
executionPhase = AFTER_TEST_METHOD,
config = @SqlConfig(transactionMode = ISOLATED),
scripts = {"classpath:test/sqls/_truncate_tables.sql"}
)
}
)
public void countTeams_countOnEmptyTable_returnsWithEmptyList() {}
通过这个基本注释,我清理了测试文件:
@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@SqlGroup(
{
@Sql(
executionPhase = BEFORE_TEST_METHOD,
config = @SqlConfig(transactionMode = ISOLATED),
scripts = {"classpath:test/sqls/_truncate_tables.sql"}
),
@Sql(
executionPhase = AFTER_TEST_METHOD,
config = @SqlConfig(transactionMode = ISOLATED),
scripts = {"classpath:test/sqls/_truncate_tables.sql"}
)
}
)
最后我得到了这个干净的版本:
@Test
@BaseSqlGroup
public void countTeams_countOnEmptyTable_returnsWithEmptyList(){}