# Why avoid mocks

**URL:** <https://forum.elixirforum.com/t/why-avoid-mocks/1396>\
**Category:** Questions\
**Tags:** mocks\
**Created:** [August 18, 2016, 7:59pm UTC](https://forum.elixirforum.com/t/why-avoid-mocks/1396 "2016-08-18T19:59:48Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![michalmuskala](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/michalmuskala/32/20288_2.png) [@michalmuskala](https://forum.elixirforum.com/u/michalmuskala)\
**Post date:** [August 20, 2016, 5:57pm UTC](https://forum.elixirforum.com/t/why-avoid-mocks/1396/8 "2016-08-20T17:57:34Z")

</div>

I would strongly disagree that dependency injection is an OO concept. In fact I will even say that dependency injection is bread and butter of functional programming. How? Higher order functions. What is a higher order function if not a function where we “inject” the dependency - the code that executes some algorithm or performs some computations.

Injecting whole modules is no different, not really. A module is just a set of functions. Passing a module is a convenient way of passing multiple named functions. Having said that, passing the dependency through application environment is indeed a side-effect and may be not considered a good style, but it’s very simple and convenient.

When it comes to testing and it’s presence or not - I think this depends hugely on the company. I’m fortunate to work in one that requires thorough testing of all the code - code that is not tested is simply not shipping to production. In fact, working on Phoenix APIs, I rarely start the application - most of the time I work just on the tests.

---

_[View the full topic](https://forum.elixirforum.com/t/why-avoid-mocks/1396)._
