I use Spring Downloadable handy annotations on my test classes, for integration tests.
@RunWith(SpringJUnit4ClassRunner.class) @SpringApplicationConfiguration(classes = Config.class) @IntegrationTest @Sql({"classpath:rollback.sql", "classpath:create-tables.sql"}) @Transactional
It was pretty ugly for me to copy / paste this whole block to each test class, so I created my own annotation @MyIntegrationTest
@SpringApplicationConfiguration(classes = Config.class) @IntegrationTest @Sql({"classpath:database-scripts/rollback.sql", "classpath:database-scripts/create-tables.sql", "classpath:database-scripts/insert-test-data.sql"}) @Transactional @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(value = RetentionPolicy.RUNTIME) @interface MyIntegrationTest { }
However, if I add @RunWith(SpringJUnit4ClassRunner.class) to my new annotation, then JUnit will work with its default running one, which is undesirable. So for now, I have to use two annotations.
@RunWith(SpringJUnit4ClassRunner.class) @MyIntegrationTest
I assume this is normal now, but is there a way to combine these annotations, so I could use one annotation?
source share