asking a TestProbe to throw an exception

327 views
Skip to first unread message

Caoilte O'Connor

unread,
Nov 26, 2013, 11:56:26 AM11/26/13
to akka...@googlegroups.com
Hi,
Is there any good reason why the TestProbe doesn't let you ask it to throw an exception?

Every time I want to test something that involves supervisors handling actor failure I have to replace my test probes with a proper actor. 

I'm not sure if it's a missing feature in testkit or if I'm testing my actors in the wrong way.

Regards

Caoilte

Björn Antonsson

unread,
Nov 27, 2013, 11:14:25 AM11/27/13
to akka...@googlegroups.com
Hi Caoilte,
I’m not sure that I know exactly what you are asking for. Do you want the TestProbes TestActor to throw the exception, or do you want to use the TestProbe to tell another actor to throw an exception?

If you want the TestProbes TestActor to throw an exception, then you can install an AutoPilot that throws the exception. The AutoPilot gets to inspect the messages before they are enqueued in the inspection queue, and it will be as if the TestActor throws the exception.

B/

Regards

Caoilte

--
>>>>>>>>>> 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 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/groups/opt_out.

-- 
Björn Antonsson
Typesafe – Reactive Apps on the JVM
twitter: @bantonsson

Caoilte O'Connor

unread,
Nov 28, 2013, 6:03:35 AM11/28/13
to akka...@googlegroups.com
Hi Bjorn,
Thanks for answering. It is the latter I want. I want the TestProbe's test actor to throw an exception. 

I looked at the Autopilot but I was worried that I wouldn't be using it correctly as it says "The run method must return the auto-pilot for the next message, which may be KeepRunning to retain the current one or NoAutoPilot to switch it off." If I throw an exception then I cannot return the auto-pilot for the next state. So what happens then?

c

Björn Antonsson

unread,
Nov 28, 2013, 6:08:48 AM11/28/13
to akka...@googlegroups.com
Hi,

On Thursday, 28 November 2013 at 12:03, Caoilte O'Connor wrote:
Hi Bjorn,
Thanks for answering. It is the latter I want. I want the TestProbe's test actor to throw an exception. 

I looked at the Autopilot but I was worried that I wouldn't be using it correctly as it says "The run method must return the auto-pilot for the next message, which may be KeepRunning to retain the current one or NoAutoPilot to switch it off." If I throw an exception then I cannot return the auto-pilot for the next state. So what happens then?


It will continue to use the current auto-pilot. You just have to make sure that the auto-pilot doesn’t throw exceptions indefinitely.

B/
Reply all
Reply to author
Forward
0 new messages