--
>>>>>>>>>> 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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
How about extracting the actor’s behaviour to a trait, and test that trait for the expected throw behaviour using plain old ScalaTest `intercept[Exception] { … }`, would it make sense in your case or are the interactions “very relying on the thing being an actor”?
Thanks so far!Carsten
--
>>>>>>>>>> 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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
The failure modes of an actor do make sense to view as part of its API, it is something the supervisor will have to know about and prepared to handle (or escalate). Therefore I agree with the sentiment that it should be testable as well. What I use is what I call a StepParent actor that looks like this:
class StepParent(target: ActorRef) extends Actor {override val supervisorStrategy = OneForOneStrategy() {case thr: Throwable => target ! thr; Restart // or make it configurable/controllable during the test}def receive = {case p: Props => sender ! context.actorOf(p, "child")}}... // in a testval parent = system.actorOf(Props(new StepParent(testActor)), "stepParent")parent ! Props(...) // for the actor under testval subject = expectMsgType[ActorRef]// and now test the subject
bestCarsten
--
>>>>>>>>>> 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+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
10 maj 2014 kl. 16:11 skrev Carsten Saathoff <car...@kreuzverweis.com>:That is the purpose of `TestActorRef.receive(msg, sender)`, but the restriction is that it covers only message processing which comes directly from the test procedure. In general you should not care which
actors are involved and whether your actor under test delegates a task to a temporary child actor: you should only test the externally visible behavior, which means running the actor in its natural habitat. That is what we mean when saying that unit testing is mostly a waste of time: you should concentrate on functional tests. OTOH I would love to redefine “unit testing” to mean “functional testing of a unit” (which conveniently is one actor, including its descendants).