Error while running junit : Error starting neo4j database server at '...\data\database '

Below is the code I am using to start Neo4j database server while running Junit test. (Note the machine is WIndows 10)

.withFixture (sw.toString())

It terminates with error.Below is a part of error trace.

java.lang.RuntimeException: Error starting Neo4j database server at C:\Users\ADMIN\AppData\Local\Temp\5f34f3000325d96991e8b02d689389e2\data\databases
at org.neo4j.graphdb.facade.DatabaseManagementServiceFactory.startDatabaseServer(
at org.neo4j.harness.internal.InProcessNeo4jBuilder.createNeo(

Any help will be deeply appreciated.


Better to use testcontainers.

Otherwise @michael.simons has written a great blog post about testing with Neo4j

I went through some of blogs relating to Testcontainer, but am not able to understand how to mock or create embedded instance of database for testing.

Did you read the blog from Michael?

Either you have to use the neo4j-harness in the latest version, see the code examples there.

Or with test-containers you have an integration test of all your procedures at the end.

I am using a MAC machine.. the unit test cases are running fine while using STS ide, but gives the error (error starting Neo4j database server at ...) while trying to run the test case from terminal using mvn test