How to clear a mailbox in a test channel framework

I am doing a channel test that receives a lot of messages. I can receive a message during setup, configure some state, and then I want assert (or refute ) to send another copy of this message. I think I can do this by clearing the mailbox before raising an event that will trigger a second message. How to empty channelcase mailbox?

EDIT, I fulfilled my assert_push needs of all old messages that clear them from the mailbox. This works pretty well, but it would be very inconvenient if there were a few posts

+5
source share
1 answer

Edit:: :lib.flush_receive() works :lib.flush_receive() fine! Unfortunately, it looks like the module is out of date, and I cannot find a replacement.

I was looking for a solution to this. assert_push is not practical for me, as there are many messages that are queued and not related to my test. You can use :c.flush() , which dumps all messages. Unfortunately, I don’t yet know how to prevent this from happening, so I can print it on the console.

+1
source

Source: https://habr.com/ru/post/1258493/


All Articles