libraryDependencies += "com.typesafe.akka" %% "akka-testkit" % "2.6.10" % Test
scala
class MyActorTest extends TestKit(ActorSystem("MyActorTest"))
with BeforeAndAfterAll {
override def afterAll: Unit = {
TestKit.shutdownActorSystem(system)
}
"MyActor" should {
"receive and reply messages correctly" in {
val myActor = system.actorOf(Props[MyActor])
val message = "Hello"
myActor ! message
expectMsg("Hello, I am MyActor")
}
}
}
libraryDependencies += "com.typesafe.akka" %% "akka-actor" % "2.6.10"