A mocking library for Erlang that enables dynamic mocking, call history tracking, and validation for unit testing.
Meck is a mocking library for Erlang that simplifies unit testing by allowing developers to replace modules with mock versions. It provides a flexible way to define expected behaviors, track calls, and validate that mocks are used correctly during tests.
Erlang developers writing unit tests who need to mock dependencies, particularly those using testing frameworks like EUnit or Common Test.
Developers choose Meck for its practical reliability in test environments, with features like automatic cleanup, pass-through support for partial mocking, and integration with Hamcrest matchers for advanced argument matching.
A mocking library for Erlang
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports sequences and loops of static values, enabling complex mocking scenarios like varying responses over multiple calls.
Tracks complete call history including arguments, return values, and exceptions, which simplifies debugging and test verification.
Invalidates mocks not called as expected during tests, ensuring test integrity without manual checks.
Allows pass-through to original modules with the passthrough option, enabling selective mocking without redefining all functions.
Mocking affects the entire Erlang VM, making it risky or impossible to mock core modules like erlang or those with NIFs, as noted in the caveats.
Mocks do not apply to module-local function invocations, which can lead to unexpected behavior and requires workarounds in test design.
Requires careful use of the no_link flag and manual unloading to avoid flaky tests due to process isolation in Common Test suites.