Testing
For the Akka Classic documentation of this feature see Classic Testing.
Module info
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' }
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 versions | 2.12.10, 2.13.1 |
JPMS module name | akka.actor.testkit.typed |
License | |
Readiness level | Supported, Lightbend Platform Subscription provides support
Since 2.6.0, 2019-11-06
|
Home page | https://akka.io/ |
API documentation | |
Forums | |
Release notes | akka.io blog |
Issues | Github issues |
Sources | https://github.com/akka/akka |
Introduction
Testing can either be done asynchronously using a real ActorSystem
ActorSystem
or synchronously on the testing thread using the BehaviorTestKit
BehaviorTestKit
.
For testing logic in a Behavior
Behavior
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: