Hello everyone, I've happily been using a little helper for quite some time and Devon liked it as well so thought might propose it:
I often want to make sure that a bunch of messages were received but exactly these messages and no more. Enter assert_received_exactly - it gets a list of expected messages and it expects that each of them arrives no more than specified. (as always sorry if something like this has been proposed before, haven't seen anything) E.g. assert_received_exactly [:foo, :foo, :bar] passes if we received :foo 2 times and :bar one time. It fails if we receive :foo or :bar more often or less often. Other usage example at [1]. In the current implementation [2] receiving :baz won't fail the test as only expected values are checked. This is currently done because there are some messages being received that have nothing to do with the current thing under test (I stub out some interactions with dummy modules that send messages instead of doing work like [3]). I realize it's a very thin wrapper atm but having it part pf ExUnit would probably still help people and make tests better overall. Happy to try & convert it to a macro and PR it if this helper is desired :) (probably also with more custom error messages) Thanks for considering and for great community work and a great language! :) Tobi [1] https://github.com/PragTob/benchee/blob/3b60c17b067a7e7503cb0fb6e40bdc92ffde3fbd/test/benchee/benchmark/runner_test.exs#L854-L867 [2] https://github.com/PragTob/benchee/blob/master/test/support/test_helpers.ex#L23-L29 [3] https://devonestes.herokuapp.com/my-new-favorite-elixir-testing-trick -- http://www.pragtob.info/ -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/e9f08407-830b-0e38-db5d-34d0672f247c%40gmail.com. For more options, visit https://groups.google.com/d/optout.