Beam Bloggers Webring
Read post

Mocks Are Your Friends, Not Your Servants

A philosophical and practical argument for treating mocks as first-class participants in tests rather than disposable stubs. The author distinguishes between mocks (nouns — contract-enforcing collaborators) and stubs (canned-response fakes), arguing that mocks should act as protagonists that drive the testing narrative. Using Elixir's OTP and the Finitomata FSM library as a case study, the post demonstrates how mock-as-listener patterns eliminate race conditions in async tests by replacing Process.sleep with deterministic assert_receive synchronization. The Finitomata.ExUnit module is presented as a concrete implementation of this philosophy using Mox.

    #testing#authentication#elixir
May 17•7m read time•From rocket-science.ru
Post cover image
Table of contents
Mock Is a NounStubs Are for Candles, Not for SoftwarePromote Your Mocks to Lead ActorsOTP, Race Conditions, and the Debugger You DeserveListeners, Visibility, and the Joy of Seeing What HappensFinitomata: A Case Study in Mock-Driven TestingThe Moral
274 Impressions
Beam Bloggers Webring's image
Beam Bloggers Webring

BeamBloggers is a specialized resource center for Apache Beam enthusiasts, offering an extensive arr...

20 Followers

•

291 Upvotes

Would you recommend this post?

Copy link
WhatsApp
Facebook
X
New Squad
  • © 2026 Daily Dev Ltd.
  • Guidelines
  • Explore
  • Tags
  • Sources
  • Squads
  • Leaderboard