Right now it's exactly the same as multiple
assert_received/refute_received as this is the implementation atm :D
(https://github.com/PragTob/benchee/blob/master/test/support/test_helpers.ex#L23-L29)

Agreed it somehow implies order which it doesn't (and imo shouldn't)
check. No idea for a better name though - I'd make sure for the docs to
take note of it.

It's just a thin wrapper so yeah that's the question if it's worth to
add it. It's a short cut that I like in its expressiveness but I can see
that this doesn't mean it should be part of ExUnit :)

It could be expanded though Process.info(self(), :messages) to also see
that no other messages were received as a variant or to explicitly allow
other messages to be received. Like: assert that we received exactly
these messages, except for messages that look like this - they are okay
too. Might be too complex for one function as usage though.

Anyhow, just wanted to check if people thought it was a good idea :)
Thanks for the reply!

On 02/11/2018 04:59 PM, José Valim wrote:
> How is that different from asserting each of them was received followed
> by a refute_received _? My concern about such helper is that it may
> imply an ordering which we likely won’t assert. Although one could argue
> the same about multiple assert_received calls.
> 
> On Sun, Feb 11, 2018 at 16:04 Tobias Pfeiffer <prag...@gmail.com
> <mailto:prag...@gmail.com>> wrote:
> 
>     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
>     <mailto:elixir-lang-core%2bunsubscr...@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.
> 
> -- 
> 
> 
> *
> *José Valim*
> www.plataformatec.com.br <http://www.plataformatec.com.br/>
> Founder and *
> Director of R&D
> *
> *
> 
> -- 
> 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
> <mailto:elixir-lang-core+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JunuWKNwUkuqPD6-fOCLC_WZDLas%2BsmKHE4L978uNzMg%40mail.gmail.com
> <https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4JunuWKNwUkuqPD6-fOCLC_WZDLas%2BsmKHE4L978uNzMg%40mail.gmail.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

-- 
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/c19428b6-d826-10f4-9525-863fce138a54%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to