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

**URL:** <https://discuss.akka.io/t/akka-test-how-do-i-expectterminated-for-two-actors-in-java-api/5232>\
**Category:** Akka Libraries\
**Created:** [October 14, 2019, 10:23am UTC](https://discuss.akka.io/t/akka-test-how-do-i-expectterminated-for-two-actors-in-java-api/5232 "2019-10-14T10:23:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![baltiyskiy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/baltiyskiy/32/1053_2.png) [@baltiyskiy](https://discuss.akka.io/u/baltiyskiy)\
**Post date:** [October 14, 2019, 10:23am UTC](https://discuss.akka.io/t/akka-test-how-do-i-expectterminated-for-two-actors-in-java-api/5232/1 "2019-10-14T10:23:33Z")

</div>

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:

```auto
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?

---

<div class="post-metadata">

**Author:** ![chbatey](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/chbatey/32/98_2.png) [@chbatey](https://discuss.akka.io/u/chbatey)\
**Post date:** [October 14, 2019, 10:45am UTC](https://discuss.akka.io/t/akka-test-how-do-i-expectterminated-for-two-actors-in-java-api/5232/2 "2019-10-14T10:45:36Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![baltiyskiy](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.akka.io/baltiyskiy/32/1053_2.png) [@baltiyskiy](https://discuss.akka.io/u/baltiyskiy)\
**Post date:** [October 14, 2019, 12:23pm UTC](https://discuss.akka.io/t/akka-test-how-do-i-expectterminated-for-two-actors-in-java-api/5232/3 "2019-10-14T12:23:54Z")

</div>

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