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

已查看 132 次
跳至第一个未读帖子

Rich Dougherty

未读,
2012年12月5日 09:18:272012/12/5
收件人 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

未读,
2012年12月5日 13:45:132012/12/5
收件人 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.
回复全部
回复作者
转发
0 个新帖子