Akka-test: how do I expectTerminated for two actors in Java API?

In my test, I have two actors, A and B. I need to verify that both of them are terminated.

Obviously, this doesn’t work:

testKit.expectTerminated(actorA);
testKit.expectTerminated(actorB);

That’s because actor B’s termination message can become before A’s, and the first assertion will fail.

I see that in Scala API, there’s a nifty method expectMsgAllClassOf(), but there’s no such method in Java API.

What’s the expected way to do this in Java API?

You could do testKit.expectClass(Terminated.class) twice then do your verification with normal asserations.

1 Like

Thanks. Is there any specific reason why there’s no expectMsgAllClassOf() in Java API?