I am trying to insert events before I try to execute some commands. I want to get my behaviour in a state ready for particular test, without needing to rerun all the commands, like database fixtures in regular testing.
I am using:
akka.persistence.testkit.javadsl.EventSourcedBehaviorTestKit`
akka.actor.testkit.typed.javadsl.ActorTestKit`
akka.persistence.testkit.javadsl.PersistenceTestKit
I create my test kits:
static final ActorTestKit testKit = ActorTestKit.create(ConfigFactory.load("my.test.conf"));
static final EventSourcedBehaviorTestKit<Command, Event, State> eventSourcedTestKit = EventSourcedBehaviorTestKit.create(
testKit.system(),
MyPersistentBehaviour.create()
);
and then I try to do:
eventSourcedTestKit.persistenceTestKit().persistForRecovery(
"1",
//List of my akka events
);
eventSourcedTestKit.restart();
but as soon as I try to runCommand
those events I persisted aren't applied. I also had to disable serialization if that changes anything? (it wasn't picking up my custom serialization, and it was always falling back to default java serializer)
here is config I used:
akka {
persistence {
testkit {
journal.pluginid {
class = "akka.persistence.testkit.PersistenceTestKitPlugin"
}
events {
serialize = false
}
}
journal.plugin = "akka.persistence.testkit.journal.pluginid"
}
}
Is this even a good way to do it?
Aucun commentaire:
Enregistrer un commentaire