I’m writing an acceptance test using Specs2.
I want to use ImpermanentGraphDatabase in order to have an in-memory Neo4j graph; ideal for integration testing.
I set up Spring-Data for Neo4j and my Spring file configuration contains:
<bean id="graphDatabaseService" class="org.neo4j.test.ImpermanentGraphDatabase" destroy-method="shutdown"/>
I wonder whether the option destroy-method="shutdown"is taking in account with Specs2 instead of usual JUnit, in order to isolate each Spec’s example.
To sum up: Would each example have its own in-memory graph instance or it would be shared to all of them?
I guess that it’s not applicable since specs2 use the same Specification instance for all these Spec’s examples execution. Indeed, with the Specs2’s functional style, only is() method is called englobing all examples in one instance.
I tried also to implement the BeforeExample trait in order to clean database at each example but… with a Given/Then/When style, it seems that the whole is considered as a unique example. Indeed, the separator is ^ instead of traditional !, the latter representing one example.
I would like to clean in-memory database (ImpermanentGraphDatabse) before each step (Given or When or Then step)
My understanding of your problem is that you want a “fresh” database before each group of Given/When/Then steps.
In order to do this you can either:
specify the action explicitly before each group of Given/When/Then steps
use functions to declare each group and map a cleanup step before each
use the
mapfunction of the Specification to do it generically