So, I've started a new Neo4j app using start.spring.io, and added the code from your Medium post about testing with TestContainers and
The problem I have is that, with a "real" Neo4j configuration defined in the context of the
@SpringBootApplication, the context of the test class won't startup because it's got a conflicting config.
The actual errors are:
java.lang.IllegalStateException: Failed to load ApplicationContext
Caused by: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'configuration' defined in com.grahamlea.neo4j_test_app.model.RepositoryTest$Config: Cannot register bean definition [SNIP] defined in com.grahamlea.neo4j_test_app.model.RepositoryTest$Config] for bean 'configuration': There is already [SNIP] defined in com.grahamlea.neo4j_test_app.GraphApiApplication] bound.
Earlier in the week I was playing around with it to try and get it working, I think by giving the beans different names in the
@TestConfiguration, and I somehow got it set up so that data was being inserted into the test database but queries were going against my local Neo4j instance.
I've uploaded the code here if you want to have a look: https://github.com/GrahamLea/neo4j-test-app/
I'd really appreciate your help in getting it to work with one Neo4j config for the app to use and a different one for tests. My Spring test framework knowledge is a little rusty, so it's totally possible I'm doing something stupid that has a very simple fix.