diff --git a/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/javadsl/ActorTestKit.scala b/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/javadsl/ActorTestKit.scala index b107a3af67..f928fa6f28 100644 --- a/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/javadsl/ActorTestKit.scala +++ b/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/javadsl/ActorTestKit.scala @@ -153,10 +153,14 @@ final class ActorTestKit private[akka] (delegate: akka.actor.testkit.typed.scala def spawn[T](behavior: Behavior[T], name: String, props: Props): ActorRef[T] = delegate.spawn(behavior, name, props) /** * Stop the actor under test and wait until it terminates. + * It can only be used for actors that were spawned by this `ActorTestKit`. + * Other actors will not be stopped by this method. */ def stop[T](ref: ActorRef[T]): Unit = delegate.stop(ref) /** * Stop the actor under test and wait `max` until it terminates. + * It can only be used for actors that were spawned by this `ActorTestKit`. + * Other actors will not be stopped by this method. */ def stop[T](ref: ActorRef[T], max: Duration): Unit = delegate.stop(ref, max.asScala) diff --git a/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala b/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala index 4f83efffd5..179f282246 100644 --- a/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala +++ b/akka-actor-testkit-typed/src/main/scala/akka/actor/testkit/typed/scaladsl/ActorTestKit.scala @@ -177,6 +177,8 @@ final class ActorTestKit private[akka] (val name: String, val config: Config, se /** * Stop the actor under test and wait until it terminates. + * It can only be used for actors that were spawned by this `ActorTestKit`. + * Other actors will not be stopped by this method. */ def stop[T](ref: ActorRef[T], max: FiniteDuration = timeout.duration): Unit = try { Await.result(internalSystem ? { x: ActorRef[ActorTestKitGuardian.Ack.type] ⇒ ActorTestKitGuardian.StopActor(ref, x) }, max) diff --git a/akka-docs/src/main/paradox/typed/testing.md b/akka-docs/src/main/paradox/typed/testing.md index d1c78b9949..45603a85ef 100644 --- a/akka-docs/src/main/paradox/typed/testing.md +++ b/akka-docs/src/main/paradox/typed/testing.md @@ -211,6 +211,8 @@ Scala Java : @@snip [AsyncTestingExampleTest.java](/akka-actor-testkit-typed/src/test/java/jdocs/akka/actor/testkit/typed/javadsl/AsyncTestingExampleTest.java) { #test-stop-actors } +The `stop` method can only be used for actors that were spawned by the same `ActorTestKit`. Other actors +will not be stopped by that method. ### Test framework integration