dashbitco

dashbitco/mox

Elixir

Mocks and explicit contracts in Elixir

1.4k stars
78 forks
slow
GitHub

1.4k

Stars

78

Forks

6

Open issues

5

Contributors

AI Analysis

Mox is a library for creating concurrent mocks in Elixir based on explicit behavior contracts. It enables concurrent testing with async support while following principled mocking practices that emphasize pattern matching and function clauses over complex expectation rules.

Documentation 9/10
Activity 8/10
Community 8/10
Code quality 9/10

Inferred from signals mentioned in the README (tests, CI, type safety) — not a review of the actual code.

Overall score 9/10

AI's overall editorial judgment — not an average of the bars above, can weigh other factors too.

testing mocking elixir concurrency contracts
Actively maintained Well documented Popular Production ready
Deep Analysis · Based on README and public signals
1w ago

Mox: Elixir's structured mock library enforcing contracts through behaviours and concurrency

Mox is a testing library for Elixir that provides concurrent mocks based on behaviour contracts, rather than ad-hoc dynamic mocking. It enforces a testing philosophy emphasizing explicit contracts, pattern matching, and async-safe test isolation. Created by Dashbit and actively maintained, it appears to be the standard mock library for Elixir projects that follow strict testing disciplines. Adoption is embedded within the Elixir ecosystem rather than universally known.

Origin

Mox originated in 2017 from Plataformatec (later Dashbit) as a response to testing philosophy concerns documented in the 'Mocks and explicit contracts' blog post. It formalizes contract-driven testing for Elixir's concurrent model. Ownership transitioned to Dashbit, which has maintained steady development and documentation.

Growth

Growth has been moderate and stable rather than explosive. The 1,396 stars reflect acceptance within the Elixir community but modest absolute visibility. Recent activity (last push 2026-05-06, only 1 star in last 7 days) suggests maturity plateau: the library has reached its intended audience and continues steady maintenance rather than pursuing viral adoption. Growth appears driven by Elixir adoption trends and word-of-mouth within the community rather than marketing or major features.

In production

Adoption not verified in provided metadata. No case studies, testimonials, or company usage lists appear in README. The library is distributed via hex.pm (Elixir's package manager) and appears to be the de facto standard in Elixir testing tutorials and community discourse, but concrete production adoption metrics are absent. Presence on hex.pm and in CI workflows suggests real usage, but scale is unquantified.

Code analysis
Architecture

Based on README, Mox follows a behaviour-driven design: mocks must be defined against Elixir behaviours (interfaces), preventing ad-hoc mocking. Likely uses Elixir's module system and concurrency primitives (processes) to isolate mock state per test, enabling `async: true` test modes. The library appears to leverage pattern matching and function clauses rather than complex expectation DSLs.

Tests

README shows CI badge and coverage badge (Coveralls), indicating active test coverage tracking. Specific coverage percentage not documented in provided excerpt, but presence of both signals suggests reasonable coverage discipline.

Maintenance

Last push 2026-05-06 (55 days before evaluation date) indicates active maintenance. CI workflows present and apparently passing. No recent abandonment signals. Release cadence not explicitly stated in README, but steady maintenance over 9 years (created 2017) with no long gaps suggests committed long-term stewardship. Growth in stars per week (1 in last 7 days) is low but consistent with a mature, stable library that has found its niche.

Honest verdict

ADOPT IF: you are building Elixir applications that require async-safe, contract-enforced mocking and value explicit testing philosophy. AVOID IF: you need mocking for languages outside Elixir, or if your team prefers ad-hoc/flexible mock generation without strict behaviour contracts. MONITOR IF: you are evaluating Elixir testing frameworks for the first time—Mox is the structured choice, but simpler ad-hoc stubbing may suffice for smaller projects.

Independent dimensions

Mainstream potential

3/10

Technical importance

7/10

Adoption evidence

4/10

Risks
  • Adoption limited to Elixir ecosystem; no value outside that language.
  • Requires architectural discipline: projects must define behaviours before writing implementations, raising onboarding friction for teams unfamiliar with contract-driven design.
  • Philosophy-dependent adoption: teams rejecting the 'no ad-hoc mocks' principle will see no benefit and may face friction.
  • Ecosystem concentration risk: active maintenance dependent on Dashbit's continued stewardship; no evident community of co-maintainers.
  • Growth plateau suggests limited expansion beyond Elixir core—unlikely to broaden audience unless Elixir adoption accelerates significantly.
Prediction

Mox will likely remain the standard mock library for Elixir projects that prioritize testing discipline and concurrency safety. Adoption growth will track Elixir ecosystem growth, not outpace it. Maintenance will continue at steady, low-churn rate suitable for a mature library. No major feature expansion expected unless Elixir language changes demand it.

0 found this helpful

Newsletter

Get analyses like this every Monday

Free weekly digest of the most interesting open-source discoveries.

Languages

Elixir
99.2%
Euphoria
0.8%

Information

Language
Elixir
Last updated
2mo ago
Created
107mo ago
Analyzed with
anthropic/claude-haiku-4-5

Stars over time

Loading…

Contributors over time

Top 100 contributors only — repos with more will plateau at 100.

Loading…

Recent releases

No releases published yet.

Similar repos

beam-community

beam-community/ex_machina

ExMachina is a factory library for Elixir that simplifies test data creation...

2.1k Elixir
mockk

mockk/mockk

MockK is a mocking library designed specifically for Kotlin that enables...

5.7k Kotlin
mockoon

mockoon/mockoon

Mockoon is a desktop application and CLI tool for designing and running mock...

8.3k TypeScript Dev Tools
mirego

mirego/elixir-boilerplate

A production-ready Elixir boilerplate project maintained by Mirego that...

1.2k Elixir
vs. alternatives
ex_machina

ex_machina (2050 stars) is a factory/fixture library complementary to Mox, not a direct competitor. Serves data generation; Mox serves mock behavior. Often used together in Elixir projects.

mockk

mockk (5744 stars, Kotlin) is a mocking library for the JVM ecosystem. Operates in a different language/runtime; not a practical alternative for Elixir projects.

Hammox

Hammox (mentioned in README) is an enhanced fork that adds automatic typespec validation. It extends rather than replaces Mox, indicating Mox is the foundational tool and Hammox is optional enhancement.

Test doubles via ExUnit

ExUnit (Elixir's built-in test framework) allows manual stubbing/mocking. Mox provides structured, contract-enforced alternative; many Elixir projects likely use ExUnit's ad-hoc approach rather than Mox, suggesting Mox adoption is deliberate rather than default.

Process-based mocking patterns

Some Elixir projects use GenServer agents or process-based test doubles without Mox. Mox abstracts and standardizes this pattern, but alternative approaches exist and may be preferred for simpler scenarios.