SpringBoot 2.x, JUnit5 and DatabaseRider configuration woes
See original GitHub issueIt seems that getting this combination of tools to work together isn’t sufficiently documented, I found the examples to be lacking. However, after a couple of hours of experimentation I was able to assemble a meta-annotation for myself that works as expected:
@SpringJUnitConfig
@DBUnit(
caseInsensitiveStrategy = Orthography.LOWERCASE,
cacheConnection = false,
dataTypeFactoryClass = PostgresqlDataTypeFactory.class
)
@TestExecutionListeners(
value = {
DBRiderTestExecutionListener.class,
TransactionalTestExecutionListener.class,
DependencyInjectionTestExecutionListener.class,
DirtiesContextTestExecutionListener.class
},
mergeMode = TestExecutionListeners.MergeMode.MERGE_WITH_DEFAULTS
)
@DirtiesContext
@SpringBootTest(
webEnvironment= SpringBootTest.WebEnvironment.NONE
)
@Transactional
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
public @interface DBIntegrationTest {
}
Am I doing too much configuration here? Is there something I missed? I’m glad that I was able to find a working configuration, but the samples/examples that I have seen published lead me to believe that a simpler configuration should have been possible…
Issue Analytics
- State:
- Created 4 years ago
- Comments:13 (13 by maintainers)
Top Results From Across the Web
Testing the Persistence Layer With Spring Boot @DataJpaTest
This tool utilizes DBUnit, which uses datasets to put the database into a known state. Database Rider allows the datasets to be written...
Read more >How to re-create database before each test in Spring?
I.e. how to make database recreate before each test as it happens at application first start? As you see, I tried @DirtiesContext at...
Read more >junit-team/junit5 - Gitter
Though Database Rider seems to be the only extension for JUnit Jupiter posted there that provides support for DbUnit. Eric Turley.
Read more >Writing Tests with JUnit 5 | The IntelliJ IDEA Blog
In this tutorial we're going to look at features of JUnit 5 that can make it easier for us to write effective and...
Read more >Ride the database in JUnit tests with Database Rider
Database Rider closes the gap between modern Java development environment and DBUnit, bringing DBUnit closer to your JUnit tests, so database testing will ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I agree, this is something only Spring specific.
A lot of this was hidden because I didn’t know that
@DataJpaTest
adds a@Transactional
annotation, and now I’m considering changing the default and cleaning up some tests the dbunit way. They mostly already work because of the default seeding strategy anyway.no problem. i will put together an example repo for you that reproduces the issue.