1

Most examples around the Web for doing Spring integration tests with Neo4j are still on JUnit 4, and use the Neo4jRule.

How do we create a setup for Neo4j + Spring + JUnit 5?

Graham Lea
  • 5,797
  • 3
  • 40
  • 55

1 Answers1

4

If you are testing on embedded, please use the Test Harness with a simple Spring Configuration.

Here are some examples:

https://medium.com/neo4j/testing-your-neo4j-based-java-application-34bef487cc3c

https://github.com/michael-simons/neo4j-sdn-ogm-tips/tree/master/examples/using-the-test-harness https://github.com/michael-simons/neo4j-sdn-ogm-tips/tree/master/examples/using-testcontainers

https://github.com/neo4j/neo4j-java-driver-spring-boot-starter/tree/master/examples/testing-with-neo4j-harness

I would have an eye on the above ^^ This and test containers will be our way forward.

Note: The @Neo4jExtension is mostly used internally by the core team and not recommended for general use.

Graham Lea
  • 5,797
  • 3
  • 40
  • 55
Michael Simons
  • 4,640
  • 1
  • 27
  • 38
  • Michael, is it still true that Neo4jExtension is not recommended? I'm asking because this feels like it contradicts _"Support for official testing support classes. From 4.0 onwards, Neo4j provides a set of Junit 4 rules and Junit 5 extensions for community and enterprise users."_ from https://neo4j.com/docs/upgrade-migration-guide/current/migration/surface-changes/java-api/ – TWiStErRob Sep 20 '21 at 21:50