I am trying to write unit for my PersistentActor but for some reason I am not getting the message object ShoppingCart{ def props(id:String) = Props(new ShoppingCart(id)) } class ShoppingCart(id:String) extends PersistentActor with ActorLogging { ... override def receiveCommand: Receive = initial ... def initial :Receive = { case Initialized(item) => sender ! ShoppingCart(List(item)) case msg => println(s"initial got this $msg") } ... }
this is my unit test class ShoppingCartTest extends TestKit(ActorSystem("testCart")) with WordSpecLike with MustMatchers with ImplicitSender with StopSystemAfterAll { import CustomerAggregate._ implicit val actorSystem = ActorSystem("ShoppingCartTestSpec-system") implicit val timeout = Timeout(2 seconds) implicit val executionContext = actorSystem.dispatcher override def afterAll = { actorSystem.shutdown } "ShoppingCartTest" should { "Initialize cart with first item" in { val cart = TestActorRef(ShoppingCart.props("tester"), "ShoppingCart-test-actor") val items:List[Item] = List(Item("1"),Item("2"),Item("3")) cart ! Initialized(items.head) expectMsgPF(){ case ShoppingCart(t) if t.equals(items.take(1)) => true case _ => false } it seems that the message is not even reach the actor as you can see from this log ShoppingCartTestSpec-system-akka.actor.default-dispatcher-4] [akka://ShoppingCartTestSpec-system/user/ShoppingCartTest-test-actor] Message [domain.ShoppingCart$Initialized] from Actor[akka://testCart/system/testActor1#-1389989008] to TestActor[akka://ShoppingCartTestSpec-system/user/ShoppingCart-test-actor] was not delivered. [1] dead letters encountered. So what am I doing wrong ? Thanks Avi -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+unsubscr...@googlegroups.com. To post to this group, send email to akka-user@googlegroups.com. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.