Packages

final class ActorTestKit extends AnyRef

Java API: Test kit for asynchronous testing of typed actors. Provides a typed actor system started on creation, that can be used for multiple test cases and is shut down when shutdown is called.

The actor system has a custom guardian that allows for spawning arbitrary actors using the spawn methods.

Designed to work with any test framework, but framework glue code that calls shutdownTestKit after all tests has run needs to be provided by the user or with TestKitJunitResource.

Use TestKit.create factories to construct manually or TestKitJunitResource to use together with JUnit tests

For synchronous testing of a Behavior see BehaviorTestKit

Source
ActorTestKit.scala
Linear Supertypes
Type Hierarchy
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ActorTestKit
  2. AnyRef
  3. Any
Implicitly
  1. by any2stringadd
  2. by StringFormat
  3. by Ensuring
  4. by ArrowAssoc
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Value Members

  1. def createTestProbe[M](name: String, clazz: Class[M]): TestProbe[M]

    Shortcut for creating a new named test probe for the testkit actor system

    Shortcut for creating a new named test probe for the testkit actor system

    M

    the type of messages the probe should accept

  2. def createTestProbe[M](name: String): TestProbe[M]

    Shortcut for creating a new named test probe for the testkit actor system

    Shortcut for creating a new named test probe for the testkit actor system

    M

    the type of messages the probe should accept

  3. def createTestProbe[M](clazz: Class[M]): TestProbe[M]

    Shortcut for creating a new test probe for the testkit actor system

    Shortcut for creating a new test probe for the testkit actor system

    M

    the type of messages the probe should accept

  4. def createTestProbe[M](): TestProbe[M]

    Shortcut for creating a new test probe for the testkit actor system

    Shortcut for creating a new test probe for the testkit actor system

    M

    the type of messages the probe should accept

  5. def scheduler: Scheduler

    The scheduler of the testkit actor system

  6. def shutdownTestKit(): Unit

    Terminate the actor system and the testkit

  7. def spawn[T](behavior: Behavior[T], name: String, props: typed.Props): typed.ActorRef[T]

    Spawn a new named actor under the testkit user guardian with the given props and return the ActorRef for the spawned actor, note that spawning actors with the same name in multiple test cases will cause failures.

  8. def spawn[T](behavior: Behavior[T], props: typed.Props): typed.ActorRef[T]

    Spawn a new auto-named actor under the testkit user guardian with the given props and return the ActorRef for the spawned actor

  9. def spawn[T](behavior: Behavior[T], name: String): typed.ActorRef[T]

    Spawn a new named actor under the testkit user guardian and return the ActorRef for the spawned actor, note that spawning actors with the same name in multiple test cases will cause failures.

  10. def spawn[T](behavior: Behavior[T]): typed.ActorRef[T]

    Spawn a new auto-named actor under the testkit user guardian and return the ActorRef for the spawned actor

  11. def stop[T](ref: typed.ActorRef[T], max: Duration): Unit

    Stop the actor under test and wait max until it terminates.

    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.

  12. def stop[T](ref: typed.ActorRef[T]): Unit

    Stop the actor under test and wait until it terminates.

    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.

  13. def system: typed.ActorSystem[Void]

    The actor system running for this testkit.

    The actor system running for this testkit. Interaction with the user guardian is done through methods on the testkit which is why it is typed to Void.

  14. def testKitSettings: TestKitSettings
  15. def timeout: Timeout

    The default timeout as specified with the config/akka.actor.testkit.typed.TestKitSettings