# Mocks and explicit contracts

DevFeed: [Mocks and explicit contracts](<https://devfeed.tech/articles/mocks-and-explicit-contracts-44010.md>)

Original publisher: [Read original article](<https://dashbit.co/blog/mocks-and-explicit-contracts>)

Author: José Valim

Published: 2015-10-14T00:00:00Z

Content type: article

Language: en

Sources: [Dashbit Blog](<https://devfeed.tech/sources/dashbit-blog.md>)

Topics: [Mocking](<https://devfeed.tech/topics/mocking.md>), [Testing](<https://devfeed.tech/topics/testing.md>), [Elixir](<https://devfeed.tech/topics/elixir.md>), [interface](<https://devfeed.tech/topics/interface.md>), [API](<https://devfeed.tech/topics/api.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [elixir](<https://devfeed.tech/tags/elixir.md>), [interface](<https://devfeed.tech/tags/interface.md>), [mocking](<https://devfeed.tech/tags/mocking.md>), [phoenix](<https://devfeed.tech/tags/phoenix.md>), [rails](<https://devfeed.tech/tags/rails.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tests](<https://devfeed.tech/tags/tests.md>)

## AI overview

This article argues that mocks should not replace explicit interfaces between software components. It uses an external Twitter API example to explain how excessive mocking couples tests to implementation details, can break when an HTTP client changes, and can prevent concurrent test execution in Elixir. It proposes configuring an interchangeable client for tests instead.

## Source excerpt

Our test tools often make it very easy to abuse mocks. This post provides some guidelines on using them properly by relying on explicit contracts.