Since it is Actor-2 that is violating its contract, why don’t you write a test that inspects the response of Actor-2 to a Restart message? Sending to `self` is tracked by EffectfulActorContext and Actor-1’s role would be stubbed by an Inbox that you can inspect as well. The post condition should be that `self` gets the Initialize but nothing else, and that the Inbox (for Actor-1) gets the Initialized but nothing else.
Then another test verifies the reaction of Actor-1 to the Initialized, ensuring that `Run` is sent to the Inbox standing in for Actor-2. There is no need to write any asynchronous test for these cases. Asynchronous tests are only necessary to find holes in the individual actors’ contracts, i.e. if step 2.3 was a spec bug then a test with real actors and scalatest’s async test support would find it (assuming that double-Run leads to observable errors—if not, then why do you care?). Regards, Roland > 18 aug. 2017 kl. 07:56 skrev [email protected]: > > I am trying to test following scenario which has a bug in the code but I am > not able to write automated test for this!! > > 1. Actor-1 sends a 'Restart' message to Actor-2 (Note that the restart is > business specific message and not actor restart) > 2. Actor-2 does three things => 2.1: Sends 'Initialize' message to self > 2.2: Sends 'Initialized' message to Actor-1 > 2.3: Sends 'Run' message to self > 3. Actor-1 receives 'Initialized' message from Actor-2 and sends 'Run' > message to Actor-2 > > As you can notice the bug here, Actor-2 is sending 'Run' message to self as > well as Actor-1 is sending 'Run' message to Actor-2. > > Both EffectfulActorContex and StubbedActorContext does not support two way > communication between actors. > And there is no way, I can assert on which Message received by Actor without > using testkit. > > I can see there is a issue opened 4 months back for asynchronous testing of > actors. (testkit for asynchronous testing #22764) > > Meanwhile is there any way to test the scenario which i just described above? > > -- > >>>>>>>>>> Read the docs: http://akka.io/docs/ <http://akka.io/docs/> > >>>>>>>>>> Check the FAQ: > >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html > >>>>>>>>>> <http://doc.akka.io/docs/akka/current/additional/faq.html> > >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user > >>>>>>>>>> <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] > <mailto:[email protected]>. > To post to this group, send email to [email protected] > <mailto:[email protected]>. > Visit this group at https://groups.google.com/group/akka-user > <https://groups.google.com/group/akka-user>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- >>>>>>>>>> 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 https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
