Polly Chang
2018-09-18 17:30:36 UTC
Hi,
I am using Akka Testkit in a project, and I've always used expectNoMsg()
with the default timeout of three seconds. However, another developer says
that we should be using expectNoMsg(0.seconds) instead so that our tests
don't take longer and longer to run as we add more of these asserts. I
agree with the goal but am unsure about whether it's safe to use a 0 second
timeout. The rational about using 0 seconds is that since we are invoking
expectNoMsg on a TestActorRef, and the ! function to/in a TestActorRef is a
synchronous operation, waiting for 0 seconds is enough. I tested with a
couple of my test cases and found that the tests did fail if an unexpected
message is sent. But is that reliable? Should we adopt
"expectNoMsg(0.seconds)" as a testing best practice? Please let me know if
there are any subtleties or caveats to be aware of.
Thanks,
Polly
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user google-group soon.
** This group will soon be put into read-only mode, and replaced by discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
I am using Akka Testkit in a project, and I've always used expectNoMsg()
with the default timeout of three seconds. However, another developer says
that we should be using expectNoMsg(0.seconds) instead so that our tests
don't take longer and longer to run as we add more of these asserts. I
agree with the goal but am unsure about whether it's safe to use a 0 second
timeout. The rational about using 0 seconds is that since we are invoking
expectNoMsg on a TestActorRef, and the ! function to/in a TestActorRef is a
synchronous operation, waiting for 0 seconds is enough. I tested with a
couple of my test cases and found that the tests did fail if an unexpected
message is sent. But is that reliable? Should we adopt
"expectNoMsg(0.seconds)" as a testing best practice? Please let me know if
there are any subtleties or caveats to be aware of.
Thanks,
Polly
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user google-group soon.
** This group will soon be put into read-only mode, and replaced by discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
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
---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 https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.