You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use @DataJpaTest annotation on JUnit5 test class. But I have few test classes with the same configuration. I added an interface to extract common methods and configuration. But there's a problem with @DataJpaTest annotation. If it's on the test class then everything is good. But if I put it on to the interface which test class extending then it's not working. It seems to be good to extend using annotation @DataJpaTest to interfaces.
@DataJpaTest // It worksclassMyTestClass {
}
// ----------interfaceMyCommonTestInterface1 { ... } // it works too
@DataJpaTest
classMyTestClass11: MyCommonTestInterface1 {}
@DataJpaTest
classMyTestClass12: MyCommonTestInterface1 {}
// ----------
@DataJpaTest
interfaceMyCommonTestInterface2 { ... } // Don't work but I wanna remove duplication
classMyTestClass21: MyCommonTestInterface2 {}
classMyTestClass22: MyCommonTestInterface2 {}
The real case is if you're using testcontainers and wanna start container ones for all tests (to save time), you need to create static container in the base class. I could be using abstract class for such case but I have not 1 container but N (cont_1, ..., cont_n), for example Postgres, Elastic, MyOther Service and I wanna start cont_1, cont_2 for 10 tests and start cont_5, cont_6 for another 20 tests and... Because I use interfaces like Scala traits to add them independently.
The text was updated successfully, but these errors were encountered:
@DataJpaTest is a Spring Boot annotation. I'm not sure where details get lost. In any case, please report the issue against the Spring Boot issue tracker.
I use @DataJpaTest annotation on JUnit5 test class. But I have few test classes with the same configuration. I added an interface to extract common methods and configuration. But there's a problem with @DataJpaTest annotation. If it's on the test class then everything is good. But if I put it on to the interface which test class extending then it's not working. It seems to be good to extend using annotation @DataJpaTest to interfaces.
The real case is if you're using testcontainers and wanna start container ones for all tests (to save time), you need to create static container in the base class. I could be using abstract class for such case but I have not 1 container but N (cont_1, ..., cont_n), for example Postgres, Elastic, MyOther Service and I wanna start cont_1, cont_2 for 10 tests and start cont_5, cont_6 for another 20 tests and... Because I use interfaces like Scala traits to add them independently.
The text was updated successfully, but these errors were encountered: