Testing

Note

For the Akka Classic documentation of this feature see Classic Testing.

Project Info: Akka Actor Testkit (typed)
Artifact
com.typesafe.akka
akka-actor-testkit-typed
2.6-SNAPSHOT
JDK versions
Adopt OpenJDK 8
Adopt OpenJDK 11
Scala versions2.12.10, 2.13.0
JPMS module nameakka.actor.testkit.typed
License
Readiness level
Since 2.6.0, 2019-12-31
Home pagehttps://akka.io/
API documentation
Forums
Release notesakka.io blog
IssuesGithub issues
Sourceshttps://github.com/akka/akka

Dependency

To use Actor TestKit add the module to your project:

sbt
libraryDependencies += "com.typesafe.akka" %% "akka-actor-testkit-typed" % "2.6-SNAPSHOT" % Test
Maven
<dependency>
  <groupId>com.typesafe.akka</groupId>
  <artifactId>akka-actor-testkit-typed_2.12</artifactId>
  <version>2.6-SNAPSHOT</version>
  <scope>test</scope>
</dependency>
Gradle
dependencies {
  test group: 'com.typesafe.akka', name: 'akka-actor-testkit-typed_2.12', version: '2.6-SNAPSHOT'
}

We recommend using Akka TestKit with ScalaTest:

sbt
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.7" % Test
Maven
<dependency>
  <groupId>org.scalatest</groupId>
  <artifactId>scalatest_2.12</artifactId>
  <version>3.0.7</version>
  <scope>test</scope>
</dependency>
Gradle
dependencies {
  test group: 'org.scalatest', name: 'scalatest_2.12', version: '3.0.7'
}

Introduction

Testing can either be done asynchronously using a real ActorSystemActorSystem or synchronously on the testing thread using the BehaviorTestKitBehaviorTestKit.

For testing logic in a BehaviorBehavior in isolation synchronous testing is preferred, but the features that can be tested are limited. For testing interactions between multiple actors a more realistic asynchronous test is preferred.

Those two testing approaches are described in:

Found an error in this documentation? The source code for this page can be found here. Please feel free to edit and contribute a pull request.