testing that a message is *not* send

44 views
Skip to first unread message

Kostas kougios

unread,
Oct 27, 2015, 11:35:00 AM10/27/15
to Akka User List
I want to test the negative of a use case, when a msg shall not be send.

TestKit doesn't seem to have something to say dontExpectAnyMessage. TestProbe has a field of how many msgs are available to the probe, but that seems like a hack.

I've also tried mocking ActorRef and verify(ref.tell..., 0 times) but I get a classcast exception.

java.lang.ClassCastException: akka.actor.ActorRef$$EnhancerByMockitoWithCGLIB$$12648026 cannot be cast to akka.actor.ScalaActorRef

It seems there is no workaround for this class cast exception as the akka class hierarchy doesn't allow it.

What's the way to verify a msg is not send?

Thanks

Akka Team

unread,
Oct 27, 2015, 11:51:06 AM10/27/15
to Akka User List
Hi Kostas,

The usual way to do this is to use expectNoMsg() which will wait for a configurable amount of time and fail if a message arrives during that time.

-Endre

--
>>>>>>>>>> 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.



--
Akka Team
Typesafe - Reactive apps on the JVM
Blog: letitcrash.com
Twitter: @akkateam

Konstantinos Kougios

unread,
Oct 27, 2015, 11:54:35 AM10/27/15
to akka...@googlegroups.com
aha ok thanks, I will use that.
You received this message because you are subscribed to a topic in the Google Groups "Akka User List" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/akka-user/TJfFIy5f3qs/unsubscribe.
To unsubscribe from this group and all its topics, send an email to akka-user+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages