Hi, There seems to be a small time window during the actor creation when the code can execute in parallel even though you are using the calling thread dispatcher. Since the dispatcher was specifically desgned for the TestActorRef, I don't think that we will try to fix it for the general avtor startup.
I would try to use a version of Mockito (1.8.5 or newer) with support for verification with timeouts to test asynchronous method invocations. B/ On 26 January 2015 at 21:45:06, Wojciech Pituła ([email protected]) wrote: Here is simple example: import akka.actor.{TypedActor, ActorSystem, TypedProps} import akka.testkit.CallingThreadDispatcher import org.mockito.Mockito import org.scalatest.{BeforeAndAfterAll, WordSpec} class FooTest extends WordSpec with BeforeAndAfterAll{ trait Foo { def foo():Unit } class Bar { def bar():String = "bar" } class FooActor(bar: Bar) extends Foo { override def foo(): Unit = println(bar.bar()) } val barSpy = Mockito.spy(new Bar) val typedProps = TypedProps(classOf[Foo], new FooActor(barSpy)).withDispatcher(CallingThreadDispatcher.Id) val actorSystem = ActorSystem("FooTest") "FooActor" should { "call Bar#bar() when foo is called" in { val fooActor : Foo = TypedActor(actorSystem).typedActorOf(typedProps) fooActor.foo() Mockito.verify(barSpy).bar() } } override protected def afterAll(): Unit = actorSystem.shutdown() } W dniu niedziela, 25 stycznia 2015 14:07:43 UTC+1 użytkownik Wojciech Pituła napisał: Is there any way of using TestActorRef with TypedActors ? Or any other way of testing TypedActors with mocks? My problem is that with TestActorRef I can use Mockito and verify() works fine. When using TypedActor with CallingThreadDispatcher verify() works nondeterministic. -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout. -- Björn Antonsson Typesafe – Reactive Apps on the JVM twitter: @bantonsson -- >>>>>>>>>> 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 [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
