Elixir Blog Post: Help To Test Your Library

A simple yet quite effective approach to make your library a charm to test. DummyWorker sends a message back to the testing process instead of performing a real action.

Help To Test Your Library

1 Like

Awesome post! Thanks for sharing!

I’m very happy to learn such a test strategy.
One question, how does it work for async tests?

Generally, it requires no additional effort, that’s why I mentioned registering test processes on a per-message basis. There might be some caveats in particular cases, but there is no silver bullet and all of them could usually be easily resolved in place.

Messages are the actor model in a nutshell which is born to survive async environment :slight_smile:

Agreed. Some libraries make refers and check with refs. Is that idiomatic?

Yes, make_ref/0 is perfectly idiomatic, and Broadway does exactly that too.

1 Like