I am writing a module with Akka-persistance, and have run into a problem in unittesting: all the events are sourced during the test, and therefore the state changes. when i run hte test suite again, the events are replayed, so the actor does not start in the initial state it should have in the first place.
the crude solution is to delete the local event-store every time, or change the persistenceId every time. both are too crude.
is there a way to incorporate it into the the test suite?
You should use an in-memory event store when unit testing. Take a look at https://github.com/dnvriend/akka-persistence-inmemory.
With an in-memory event store, you can easily wipe the entire store before each test. See Clearing Journal and Snapshot messages section for how this is done. You should be able to adapt this to the unit testing framework of your choice.
You will also see a good boost in test setup times, and your event store will be isolated and cleaned for each test.