Re: [akka-user] Unit testing and parent reference

132 views
Skip to first unread message

Rich Dougherty

unread,
Dec 5, 2012, 9:18:27 AM12/5/12
to akka...@googlegroups.com
I guess you could make a probe actor that creates your existing actor as a child?

Rich


On Wed, Dec 5, 2012 at 3:06 PM, slane <iiro....@nemit.fi> wrote:
Hi,

This could be a stupid question but Googling did not yield any results, so here goes.

I am writing unit tests for an existing actor. The actor sends a few messages to it's parent via context.parent and I haven't been able to replace the parent reference with a probe actor. How could I accomplish that? Or is there some other way to test if the messages to the parent are being sent?

Kind regards,

Iiro L

--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://akka.io/faq/
>>>>>>>>>> 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 post to this group, send email to akka...@googlegroups.com.
To unsubscribe from this group, send email to akka-user+...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user?hl=en.
 
 

Derek Wyatt

unread,
Dec 5, 2012, 1:45:13 PM12/5/12
to akka...@googlegroups.com
Yeah, you can't do this the way that you're trying, I believe.

I would go with one of two other approaches:

  • Don't use context.parent.  Have the parent send itself as a construction parameter to the child and let the child use that reference.  Easy to inject a new one for test
  • Don't call context.parent directly.  Mix in a trait that has a method called tellParent() that tells to context.parent, which you can swap during testing.
Reply all
Reply to author
Forward
0 new messages