Skip to Main Content
Mastering Elixir
book

Mastering Elixir

by André Albuquerque, Daniel Caixinha
July 2018
Intermediate to advanced content levelIntermediate to advanced
574 pages
14h 7m
English
Packt Publishing
Content preview from Mastering Elixir

Creating mocks with Mox

As mentioned, we usually try to avoid mocks in Elixir, and especially dynamic mocks (also known as ad-hoc mocks). They're called this because they're usually created dynamically within each test, just to verify that a certain expectation was met on that test. Besides changing the global behavior and not allowing us to run our tests concurrently, this type of mocks have another disadvantage: they have no connection to the real implementation they're standing in for, which makes it possible for the mock and the real implementation to drift away, possibly resulting in having all the tests passing while your application is broken in production.

For all these reasons, we'll be creating mocks with the Mox library, created ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Testing Elixir

Testing Elixir

Andrea Leopardi, Jeffrey Matthias

Publisher Resources

ISBN: 9781788472678Supplemental Content