diff --git a/akka-testkit-typed/src/main/scala/akka/testkit/typed/internal/BehaviorTestKitImpl.scala b/akka-testkit-typed/src/main/scala/akka/testkit/typed/internal/BehaviorTestKitImpl.scala index 7751f626c3..a90d9947ff 100644 --- a/akka-testkit-typed/src/main/scala/akka/testkit/typed/internal/BehaviorTestKitImpl.scala +++ b/akka-testkit-typed/src/main/scala/akka/testkit/typed/internal/BehaviorTestKitImpl.scala @@ -123,6 +123,8 @@ private[akka] final class BehaviorTestKitImpl[T](_path: ActorPath, _initialBehav } catch handleException } + override def runOne(): Unit = run(selfInbox.receiveMessage()) + override def signal(signal: Signal): Unit = { try { currentUncanonical = Behavior.interpretSignal(current, ctx, signal) diff --git a/akka-testkit-typed/src/main/scala/akka/testkit/typed/javadsl/BehaviorTestKit.scala b/akka-testkit-typed/src/main/scala/akka/testkit/typed/javadsl/BehaviorTestKit.scala index 80fe83b8f1..64d4709d1e 100644 --- a/akka-testkit-typed/src/main/scala/akka/testkit/typed/javadsl/BehaviorTestKit.scala +++ b/akka-testkit-typed/src/main/scala/akka/testkit/typed/javadsl/BehaviorTestKit.scala @@ -62,6 +62,11 @@ abstract class BehaviorTestKit[T] { */ def selfInbox(): TestInbox[T] + /** + * The self reference of the actor living inside this testkit. + */ + def getRef(): ActorRef[T] = selfInbox.getRef() + /** * Requests all the effects. The effects are consumed, subsequent calls will only * see new effects. @@ -107,6 +112,11 @@ abstract class BehaviorTestKit[T] { */ def run(msg: T): Unit + /** + * Send the first message in the selfInbox to the behavior and run it, recording [[Effect]]s. + */ + def runOne(): Unit + /** * Send the signal to the beheavior and record any [[Effect]]s */ diff --git a/akka-testkit-typed/src/main/scala/akka/testkit/typed/scaladsl/BehaviorTestKit.scala b/akka-testkit-typed/src/main/scala/akka/testkit/typed/scaladsl/BehaviorTestKit.scala index d10090876d..2eefb07ca7 100644 --- a/akka-testkit-typed/src/main/scala/akka/testkit/typed/scaladsl/BehaviorTestKit.scala +++ b/akka-testkit-typed/src/main/scala/akka/testkit/typed/scaladsl/BehaviorTestKit.scala @@ -63,6 +63,11 @@ trait BehaviorTestKit[T] { */ def selfInbox(): TestInbox[T] + /** + * The self reference of the actor living inside this testkit. + */ + def ref: ActorRef[T] = selfInbox.ref + /** * Requests all the effects. The effects are consumed, subsequent calls will only * see new effects. @@ -113,6 +118,11 @@ trait BehaviorTestKit[T] { */ def run(msg: T): Unit + /** + * Send the first message in the selfInbox to the behavior and run it, recording [[Effect]]s. + */ + def runOne(): Unit + /** * Send the signal to the beheavior and record any [[Effect]]s */