I'm refactoring tests of Spring Batch, trying to unify integration tests for JDBC and MongoDB repository, for example:
abstract class AbstractJobRepositoryIntegrationTests {
@Autowired JobRepository jobRepository;
@Test
void foo() {
}
@Test
void bar() {
// ...
}
}
@SpringJUnitConfig(MongoDBIntegrationTestConfiguration.class)
class MongoDBJobRepositoryIntegrationTests extends AbstractJobRepositoryIntegrationTests {
}
@Transactional
@SpringJUnitConfig(locations = "/org/springframework/batch/core/repository/dao/jdbc/sql-dao-test.xml")
class JdbcJobRepositoryIntegrationTests extends AbstractJobRepositoryIntegrationTests {
@Test
void foo() {
super.foo();
}
@Test
void bar() {
super.bar();
}
}
Currently, I have to redefine all test methods for JdbcJobRepositoryIntegrationTests to enable transaction, I'd like Spring TestContext Framework provide a way to eliminate such boilerplate codes. @sbrannen
Comment From: sbrannen
Hi @quaff,
This topic has been discussed previously, in the context of both production code and integration tests.
Thus, this issue is effectively a duplicate of the following.
-
12480
-
32491
Since both of those were declined, I am going to decline this issue as well.
Regards,
Sam
Comment From: quaff
Thanks for your response, one more question, is it possible to disable transaction at subclass? Maybe Spring TestContext Framework could introduce a new transaction related annotation to resolve such use case?