Show all messages in process mailbox assert_receive


I am running a few tests and I want to make sure a process of mine receives a given message. Now the tests are failing, because assert_receive tells me I didn’t receive the proper message and then it shows me the last 10 messages.


But I don’t want to see the last 10, I want to see them all so I can pick the one I am interested in.


  1. How can I make assert_receive show me all messages in the process mailbox when the assertion fails?
  2. If this is not possible, is it possible to have access to the process mailbox before the assert concludes and fails the test ?
1 Like


If nothing else works out, you might be able to get all messages with :erlang.process_info(self(), :messages) before assert_receive.

test "..." do
  # ...
  messages = :erlang.process_info(self(), :messages)
  IO.inspect(messages, label: "messages")
  assert_receive :something
  # ...