Domain: Software Engineering / Functional Programming
Expert Persona: Senior Elixir Systems Architect and Quality Assurance Lead
Vocabulary & Tone: Technical, architectural, pragmatic, and focused on concurrency-safe testing patterns.
Part 2: Target Audience Review
Recommended Reviewers: Senior Elixir Developers, Software Architects, and Engineering Leads responsible for test suite maintainability and CI/CD performance.
Part 3: Abstract and Summary
Abstract:
This presentation, "Are you mocking me?", provides a comprehensive comparative analysis of the Elixir mocking ecosystem as of 2025. Using a tournament-style "bracket" evaluation, the session examines approximately ten libraries—including Mox, Mimic, Hammocks, and Repatch—against critical architectural requirements: asynchronous execution compatibility (async: true), cross-process mock sharing (process tree traversal), developer ergonomics, and contract safety. The evaluation concludes that while many legacy libraries fail to support Elixir's concurrency strengths, modern tools have converged toward a "blessed" syntax. The final analysis identifies Mimic as the optimal choice for contemporary Elixir development, as it combines high-level developer experience with the safety of automated type-checking and contract enforcement.
Tournament Analysis of Elixir Mocking Libraries:
0:45 The Tournament Framework: Evaluation is based on four pillars: Async testing support, cross-process mock sharing, developer ergonomics (DX), and safety/maintainability (preventing tests from deviating from production).
1:33 The Test Arena: A Phoenix LiveView application requiring external GeoCode and Weather API calls serves as the benchmarking environment.
Patch is eliminated due to a lack of compatibility with async: true.
Mock (based on the Erlang library Meck) is eliminated for the same concurrency limitations.
Repatch and Mimic advance as concurrency-safe alternatives.
5:53 Protocol-Based Mocking:Protomok and Promox are reviewed as protocol-centric options. While effective for specific patterns, they are noted for being convoluted when applied to standard module-based Phoenix contexts compared to patching libraries.
Mox is praised for its "blessed" ergonomics and syntax.
Hammocks wins the round by providing strict contract enforcement; it ensures that if a behavior's return type changes, the mock fails, preventing "lying tests."
12:35 Cross-Process Sharing (Mockery vs. Effects):Effects (FX) is highlighted for its superior ability to traverse the process tree. It allows a mock defined in a test process to be automatically discovered by async LiveView tasks without manual PID linking.
Both libraries support standard cross-process mocking and high-level DX.
Winner: Mimic. The decider is Mimic's integration of the "Ham" library, which provides the safety/type-checking of Hammocks while maintaining the flexible, behavior-free ergonomics of Mimic.
20:12 Key Takeaway – The Modern Standard: The industry-standard approach has shifted toward libraries that support the "Process Tree" pattern, allowing mocks to traverse ancestors in a way that respects Elixir's actor model without sacrificing test concurrency.