trait TestProbe[M] extends AnyRef
Create instances through the factories in the TestProbe companion.
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
Not for user extension
- Annotations
- @DoNotInherit()
- Source
- TestProbe.scala
- Alphabetic
- By Inheritance
- TestProbe
- AnyRef
- Any
- by any2stringadd
- by StringFormat
- by Ensuring
- by ArrowAssoc
- Hide All
- Show All
- Public
- All
Abstract Value Members
-
abstract
def
awaitAssert[A](a: ⇒ A): A
Evaluate the given assert every 100 ms until it does not throw an exception and return the result.
Evaluate the given assert every 100 ms until it does not throw an exception and return the result.
If the default timeout expires the last exception is thrown.
-
abstract
def
awaitAssert[A](a: ⇒ A, max: FiniteDuration): A
Evaluate the given assert every 100 ms until it does not throw an exception and return the result.
Evaluate the given assert every 100 ms until it does not throw an exception and return the result.
If the
max
timeout expires the last exception is thrown. -
abstract
def
awaitAssert[A](a: ⇒ A, max: FiniteDuration, interval: FiniteDuration): 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".
-
abstract
def
expectMessage[T <: M](max: FiniteDuration, 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
-
abstract
def
expectMessage[T <: M](max: FiniteDuration, 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
-
abstract
def
expectMessage[T <: M](obj: T): T
Same as
expectMessage(remainingOrDefault, obj)
, but using the default timeout as deadline. -
abstract
def
expectMessageType[T <: M](max: FiniteDuration)(implicit t: ClassTag[T]): T
Expect a message of type T to arrive within
max
or fail.Expect a message of type T to arrive within
max
or fail.max
is dilated. -
abstract
def
expectMessageType[T <: M](implicit t: ClassTag[T]): T
Same as
expectMessageType[T](remainingOrDefault)
, but using the default timeout as deadline. -
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". -
abstract
def
expectNoMessage(max: FiniteDuration): 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.
-
abstract
def
expectTerminated[U](actorRef: typed.ActorRef[U]): Unit
Expect the given actor to be stopped or stop within the default timeout.
-
abstract
def
expectTerminated[U](actorRef: typed.ActorRef[U], max: FiniteDuration): Unit
Expect the given actor to be stopped or stop within the given timeout or throw an AssertionError.
-
abstract
def
fishForMessage(max: FiniteDuration)(fisher: (M) ⇒ FishingOutcome): Seq[M]
Same as the other
fishForMessage
but with no hint -
abstract
def
fishForMessage(max: FiniteDuration, hint: String)(fisher: (M) ⇒ FishingOutcome): Seq[M]
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:
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.continue - continue with the next message given that the timeout has not been reached * FishingOutcomes.continueAndIgnore - continue and do not save the message in the returned list * 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 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
-
abstract
def
receiveMessage(max: FiniteDuration): M
Receive one message of type
M
.Receive one message of type
M
. Wait time is bounded by themax
duration, with an AssertionError raised in case of timeout. -
abstract
def
receiveMessage(): M
Receive one message of type
M
within the default timeout as deadline. -
abstract
def
receiveMessages(n: Int, max: FiniteDuration): Seq[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".
-
abstract
def
receiveMessages(n: Int): Seq[M]
Same as
receiveMessages(n, remaining)
but using the default timeout as deadline. -
abstract
def
ref: typed.ActorRef[M]
ActorRef for this TestProbe
-
abstract
def
remaining: FiniteDuration
Obtain time remaining for execution of the innermost enclosing
within
block or throw an AssertionError if nowithin
block surrounds this call. -
abstract
def
remainingOr(duration: FiniteDuration): FiniteDuration
Obtain time remaining for execution of the innermost enclosing
within
block or missing that it returns the given duration. -
abstract
def
remainingOrDefault: FiniteDuration
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"). -
implicit abstract
def
settings: TestKitSettings
- Attributes
- protected
-
abstract
def
stop(): Unit
Stops the TestProbe.ref, which is useful when testing watch and termination.
-
abstract
def
within[T](max: FiniteDuration)(f: ⇒ T): T
Same as calling
within(0 seconds, max)(f)
. -
abstract
def
within[T](min: FiniteDuration, max: FiniteDuration)(f: ⇒ T): T
Execute code block while bounding its execution time between
min
andmax
.Execute code block while bounding its execution time between
min
andmax
.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 enclosingwithin
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
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
- def +(other: String): String
- def ->[B](y: B): (TestProbe[M], B)
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate() @throws( ... )
- def ensuring(cond: (TestProbe[M]) ⇒ Boolean, msg: ⇒ Any): TestProbe[M]
- def ensuring(cond: (TestProbe[M]) ⇒ Boolean): TestProbe[M]
- def ensuring(cond: Boolean, msg: ⇒ Any): TestProbe[M]
- def ensuring(cond: Boolean): TestProbe[M]
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def formatted(fmtstr: String): String
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @HotSpotIntrinsicCandidate()
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toString(): String
- Definition Classes
- AnyRef → Any
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
- def →[B](y: B): (TestProbe[M], B)