Group testing of regular participants in Akka

How to do one unit test of the regular contributors. I understand there is an akka-testkit that can be used to get the base test actor object like below.

final TestActorRef<MyActor> ref = TestActorRef.create(system, props, "testA");
final MyActor actor = ref.underlyingActor();
assertTrue(actor.testMe());

      

But this does not work for regular contributors as mentioned here .

Question: how does one unit test the persistent actors method?

+3


source to share


1 answer


This question has already been answered on the mailing list in this thread . I'll deal with the answer given there a little.

When testing Actors, TestActorRef should not be overused. The best practice is to test as much as possible by sending and receiving messages from the actor. Even if you use TestActorRef, you usually use it to change the state of the actor before testing whatever you want by sending and receiving messages. Using direct access to an actor to call methods directly is not recommended. If you have more complex logic for your actor that you need to test separately, you might consider putting it in a trait or another class and testing it without an actor.



As far as testing PersistentActors is concerned, you can track progress here to test this process .

+1


source







All Articles