Packages

abstract class TestProbe[M] extends RecipientRef[M]

Java API: * Create instances through the create factories in the TestProbe companion or via ActorTestKit#createTestProbe.

A test probe is essentially a queryable mailbox which can be used in place of an actor and the received messages can then be asserted etc.

Not for user extension

Self Type
TestProbe[M] with InternalRecipientRef[M]
Annotations
@DoNotInherit()
Source
TestProbe.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TestProbe
  2. RecipientRef
  3. AnyRef
  4. Any
Implicitly
  1. by RecipientRefOps
  2. by any2stringadd
  3. by StringFormat
  4. by Ensuring
  5. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Instance Constructors

  1. new TestProbe()

Abstract Value Members

  1. abstract def awaitAssert[A](creator: Creator[A]): A

    Evaluate the given assert every 100 milliseconds until it does not throw an exception and return the result.

    Evaluate the given assert every 100 milliseconds until it does not throw an exception and return the result. A max time is taken it from the innermost enclosing within block.

  2. abstract def awaitAssert[A](max: Duration, creator: Creator[A]): A

    Evaluate the given assert every 100 milliseconds until it does not throw an exception and return the result.

    Evaluate the given assert every 100 milliseconds until it does not throw an exception and return the result.

    If the max timeout expires the last exception is thrown.

    Note that the timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

  3. abstract def awaitAssert[A](max: Duration, interval: Duration, creator: Creator[A]): A

    Evaluate the given assert every interval until it does not throw an exception and return the result.

    Evaluate the given assert every interval until it does not throw an exception and return the result.

    If the max timeout expires the last exception is thrown.

    Note that the timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

  4. abstract def expectMessage[T <: M](max: Duration, hint: String, obj: T): T

    Receive one message from the test actor and assert that it equals the given object.

    Receive one message from the test actor and assert that it equals the given object. Wait time is bounded by the given duration, with an AssertionError being thrown in case of timeout.

    returns

    the received object

  5. abstract def expectMessage[T <: M](max: Duration, obj: T): T

    Receive one message from the test actor and assert that it equals the given object.

    Receive one message from the test actor and assert that it equals the given object. Wait time is bounded by the given duration, with an AssertionError being thrown in case of timeout.

    returns

    the received object

  6. abstract def expectMessage[T <: M](obj: T): T

    Same as expectMessage(remainingOrDefault, obj), but using the default timeout as deadline.

  7. abstract def expectMessageClass[T <: M](clazz: Class[T], max: Duration): T

    Wait for a message of type M and return it when it arrives, or fail if the max timeout is hit.

    Wait for a message of type M and return it when it arrives, or fail if the max timeout is hit.

    Note that the timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

  8. abstract def expectMessageClass[T <: M](clazz: Class[T]): T

    Same as expectMessageType(clazz, remainingOrDefault),but using the default timeout as deadline.

  9. abstract def expectNoMessage(): Unit

    Assert that no message is received.

    Assert that no message is received. Waits for the default period configured as akka.actor.testkit.typed.expect-no-message-default. That timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

  10. abstract def expectNoMessage(max: Duration): Unit

    Assert that no message is received for the specified time.

    Assert that no message is received for the specified time. Supplied value is not dilated.

  11. abstract def expectTerminated[U](actorRef: typed.ActorRef[U]): Unit

    Expect the given actor to be stopped or stop within the default timeout.

  12. abstract def expectTerminated[U](actorRef: typed.ActorRef[U], max: Duration): Unit

    Expect the given actor to be stopped or stop within the given timeout or throw an AssertionError.

    Expect the given actor to be stopped or stop within the given timeout or throw an AssertionError.

    Note that the timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

  13. abstract def fishForMessage(max: Duration, hint: String, fisher: Function[M, FishingOutcome]): List[M]

    Same as the other fishForMessage but includes the provided hint in all error messages

  14. abstract def fishForMessage(max: Duration, fisher: Function[M, FishingOutcome]): List[M]

    Java API: Allows for flexible matching of multiple messages within a timeout, the fisher function is fed each incoming message, and returns one of the following effects to decide on what happens next:

    Java API: Allows for flexible matching of multiple messages within a timeout, the fisher function is fed each incoming message, and returns one of the following effects to decide on what happens next:

    * FishingOutcomes.continueAndCollect - continue with the next message given that the timeout has not been reached * FishingOutcomes.complete - successfully complete and return the message * FishingOutcomes.fail - fail the test with a custom message

    Additionally failures includes the list of messages consumed. If a message of type M but not of type T is received this will also fail the test, additionally if the fisher function throws a match error the error is decorated with some fishing details and the test is failed (making it convenient to use this method with a partial function).

    max

    Max total time without the fisher function returning CompleteFishing before failing. The timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

    returns

    The messages accepted in the order they arrived

  15. abstract def getRemaining: Duration

    Obtain time remaining for execution of the innermost enclosing within block or throw an AssertionError if no within block surrounds this call.

  16. abstract def getRemainingOr(duration: Duration): Duration

    Obtain time remaining for execution of the innermost enclosing within block or missing that it returns the given duration.

  17. abstract def getRemainingOrDefault: Duration

    Obtain time remaining for execution of the innermost enclosing within block or missing that it returns the properly dilated default for this case from settings (key "akka.actor.testkit.typed.single-expect-default").

  18. abstract def receiveMessage(max: Duration): M

    Receive one message of type M.

    Receive one message of type M. Wait time is bounded by the max duration, with an AssertionError raised in case of timeout.

  19. abstract def receiveMessage(): M

    Receive one message of type M within the default timeout as deadline.

  20. abstract def receiveSeveralMessages(n: Int, max: Duration): List[M]

    Receive n messages in a row before the given deadline.

    Receive n messages in a row before the given deadline.

    Note that the timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor".

  21. abstract def receiveSeveralMessages(n: Int): List[M]

    Same as receiveSeveralMessages(n, remaining) but using the default timeout as deadline.

  22. abstract def ref: typed.ActorRef[M]

    ActorRef for this TestProbe

  23. implicit abstract def settings: TestKitSettings
    Attributes
    protected
  24. abstract def stop(): Unit

    Stops the TestProbe.getRef, which is useful when testing watch and termination.

  25. abstract def tell(msg: M): Unit

    Send a message to the destination referenced by this RecipientRef using *at-most-once* messaging semantics.

    Send a message to the destination referenced by this RecipientRef using *at-most-once* messaging semantics.

    Definition Classes
    RecipientRef
  26. abstract def within[T](max: Duration)(f: Supplier[T]): T

    Same as calling within(0 seconds, max)(f).

  27. abstract def within[T](min: Duration, max: Duration)(f: Supplier[T]): T

    Execute code block while bounding its execution time between min and max.

    Execute code block while bounding its execution time between min and max. within blocks may be nested. All methods in this trait which take maximum wait times are available in a version which implicitly uses the remaining time governed by the innermost enclosing within block.

    Note that the max timeout is scaled using the configuration entry "akka.actor.testkit.typed.timefactor", while the min Duration is not.

    val ret = within(50 millis) {
      test ! Ping
      expectMessageType[Pong]
    }

Concrete Value Members

  1. def !(msg: M): Unit

    Send a message to the destination referenced by this RecipientRef using *at-most-once* messaging semantics.

    Send a message to the destination referenced by this RecipientRef using *at-most-once* messaging semantics.

    Implicit
    This member is added by an implicit conversion from TestProbe[M] toRecipientRefOps[M] performed by method RecipientRefOps in akka.actor.typed.RecipientRef.
    Definition Classes
    RecipientRefOps
  2. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  3. final def ##: Int
    Definition Classes
    AnyRef → Any
  4. def +(other: String): String
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toany2stringadd[TestProbe[M]] performed by method any2stringadd in scala.Predef.
    Definition Classes
    any2stringadd
  5. def ->[B](y: B): (TestProbe[M], B)
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toArrowAssoc[TestProbe[M]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @inline()
  6. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  9. def ensuring(cond: (TestProbe[M]) => Boolean, msg: => Any): TestProbe[M]
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toEnsuring[TestProbe[M]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  10. def ensuring(cond: (TestProbe[M]) => Boolean): TestProbe[M]
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toEnsuring[TestProbe[M]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  11. def ensuring(cond: Boolean, msg: => Any): TestProbe[M]
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toEnsuring[TestProbe[M]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  12. def ensuring(cond: Boolean): TestProbe[M]
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toEnsuring[TestProbe[M]] performed by method Ensuring in scala.Predef.
    Definition Classes
    Ensuring
  13. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  14. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  15. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  16. def getRef(): typed.ActorRef[M]

    ActorRef for this TestProbe

  17. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  18. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  19. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  20. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  21. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  22. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  23. def toString(): String
    Definition Classes
    AnyRef → Any
  24. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  25. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  26. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])

Shadowed Implicit Value Members

  1. val ref: RecipientRef[M]
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toRecipientRefOps[M] performed by method RecipientRefOps in akka.actor.typed.RecipientRef.
    Shadowing
    This implicitly inherited member is shadowed by one or more members in this class.
    To access this member you can use a type ascription:
    (testProbe: RecipientRefOps[M]).ref
    Definition Classes
    RecipientRefOps

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

  2. def formatted(fmtstr: String): String
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toStringFormat[TestProbe[M]] performed by method StringFormat in scala.Predef.
    Definition Classes
    StringFormat
    Annotations
    @deprecated @inline()
    Deprecated

    (Since version 2.12.16) Use formatString.format(value) instead of value.formatted(formatString), or use the f"" string interpolator. In Java 15 and later, formatted resolves to the new method in String which has reversed parameters.

  3. def [B](y: B): (TestProbe[M], B)
    Implicit
    This member is added by an implicit conversion from TestProbe[M] toArrowAssoc[TestProbe[M]] performed by method ArrowAssoc in scala.Predef.
    Definition Classes
    ArrowAssoc
    Annotations
    @deprecated
    Deprecated

    (Since version 2.13.0) Use -> instead. If you still wish to display it as one character, consider using a font with programming ligatures such as Fira Code.

Inherited from RecipientRef[M]

Inherited from AnyRef

Inherited from Any

Inherited by implicit conversion RecipientRefOps fromTestProbe[M] to RecipientRefOps[M]

Inherited by implicit conversion any2stringadd fromTestProbe[M] to any2stringadd[TestProbe[M]]

Inherited by implicit conversion StringFormat fromTestProbe[M] to StringFormat[TestProbe[M]]

Inherited by implicit conversion Ensuring fromTestProbe[M] to Ensuring[TestProbe[M]]

Inherited by implicit conversion ArrowAssoc fromTestProbe[M] to ArrowAssoc[TestProbe[M]]

Ungrouped