I am working with:
- Spring Framework
4.3.10
- JUnit
4.12
- Gradle
4.3.1
I have these two test classes
@Transactional
@RunWith(Parameterized.class)
@ContextConfiguration(classes={RootApplicationContext.class})
@ActiveProfiles(resolver=TestJdbcActiveProfilesResolver.class)
@TestExecutionListeners(listeners={LoggingTestExecutionListener.class}, mergeMode=MergeMode.MERGE_WITH_DEFAULTS)
public class PersonaServiceImplJdbcTest {
@Transactional
@RunWith(Parameterized.class)
@ContextConfiguration(classes={RootApplicationContext.class})
@ActiveProfiles(resolver=TestHibernateActiveProfilesResolver.class)
@TestExecutionListeners(listeners={LoggingTestExecutionListener.class}, mergeMode=MergeMode.MERGE_WITH_DEFAULTS)
public class PersonaServiceImplHibernateTest {
The code about the @Test
methods are the same for both Test classes, breaking the DRY
principle, the unique difference between these two test classes is the jdbc
and Hibernate
profiles working together with other such as development, mysql
, it internally through each TestXXXActiveProfilesResolver
class variation.
Until here I have 2 test classes, breaking the DRY
principle, thinking in hierarchy I am going to get 3.
How (if is possible) use one Test class where for each interaction executes two (or more) sets of profiles such as:
jdbc,development,mysql
Hibernate,development,mysql
I already have read:
But I want avoid use commands either through Maven
or Gradle
, it to keep the control through the TestXXXActiveProfilesResolver
classes.