Does this help?

http://christopher-batey.blogspot.se/2014/02/testing-scala-futures-with-scalatest-20.html

On Thu, Apr 9, 2015 at 1:27 PM, Adam Daines <dainesa...@gmail.com> wrote:

> Hi all,
>
> I've got a question in relation to the unit testing of a piece of non
> actor code that produces a Future<ActorRef> via performing an
> actorSelection().resolveOne on the ActorSystem.
>
> Within the Future.onFailure() a value is being set that I would like to
> test but the Future is making use of the ActorSystem.dispatcher() which is
> therefore causing asynchronicity issues when attempting to Assert that the
> value has been set as expected.
>
> I am currently performing a Thread.sleep() within the Unit test to provide
> enough time for the value to have been set but this is far from ideal!
>
> What is the best way to go about testing this type of code without having
> to sleep and wait? Is it possible to override the dispatcher that the
> ActorSystem returns with the CallingThreadDispatcher?
>
> Thanks.
>
> --
> >>>>>>>>>> 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.
>



-- 
Cheers,
√

-- 
>>>>>>>>>>      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.

Reply via email to