add BehaviorTestKit.runOne and .ref (#25013)

This commit is contained in:
Roland Kuhn 2018-04-30 09:17:12 +02:00 committed by Johan Andrén
parent 8cdb3feb99
commit 0dab3eba92
3 changed files with 22 additions and 0 deletions

View file

@ -123,6 +123,8 @@ private[akka] final class BehaviorTestKitImpl[T](_path: ActorPath, _initialBehav
} catch handleException } catch handleException
} }
override def runOne(): Unit = run(selfInbox.receiveMessage())
override def signal(signal: Signal): Unit = { override def signal(signal: Signal): Unit = {
try { try {
currentUncanonical = Behavior.interpretSignal(current, ctx, signal) currentUncanonical = Behavior.interpretSignal(current, ctx, signal)

View file

@ -62,6 +62,11 @@ abstract class BehaviorTestKit[T] {
*/ */
def selfInbox(): TestInbox[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 * Requests all the effects. The effects are consumed, subsequent calls will only
* see new effects. * see new effects.
@ -107,6 +112,11 @@ abstract class BehaviorTestKit[T] {
*/ */
def run(msg: T): Unit 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 * Send the signal to the beheavior and record any [[Effect]]s
*/ */

View file

@ -63,6 +63,11 @@ trait BehaviorTestKit[T] {
*/ */
def selfInbox(): TestInbox[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 * Requests all the effects. The effects are consumed, subsequent calls will only
* see new effects. * see new effects.
@ -113,6 +118,11 @@ trait BehaviorTestKit[T] {
*/ */
def run(msg: T): Unit 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 * Send the signal to the beheavior and record any [[Effect]]s
*/ */