We actually often find this rather useful - for example, if there comes a 
response from the previous test case which I did not expect,
it could fail the 2nd test as an unexpected message may come in. This helps to 
make sure there’s no spurious and additional messages sent around.
So yes, when using ImplicitSender, the assumption is that you want to make sure 
you expect all messages.

If however you want to have the tests separated completely - don’t use implicit 
sender and use test probes instead:
http://doc.akka.io/docs/akka/snapshot/scala/testing.html#using-multiple-probe-actors

Both styles make complete sense and come down to your personal testing style - 
we use both styles to test Akka itself actually.

— ktoso



On 21 November 2014 at 22:41:24, Florian Witteler 
(florian.witte...@googlemail.com) wrote:

Hi!

I was bitten by some special behaviour when testing my actorSystem with the 
help of the ImplicitSender trait.

I have two testmethods. In each of them, I send a message to an actor wrapped 
in a TestActorRef.
In the first testcase, I don't consume the answer of the actor with one of 
TestKit's expect-Methods, because I check its state directly 
(testActorRef.underlyingActor)
This causes the 2nd testcase to fail, because the first message was still in 
the receiving mailbox.

Here is an example.
https://gist.github.com/FloWi/55572324f2d3adb3d51b

Do you have any suggestion on how to make the tests independent of each other?
Or am I just using the ImplicitSender in a wrong way? (every answer must be 
consumed)

Any insights are appreciated!

Regards,
Florian
--
>>>>>>>>>> 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.
-- 
Konrad 'ktoso' Malawski
hAkker @ typesafe
http://akka.io

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