mimic
ex_machina
mimic | ex_machina | |
---|---|---|
3 | 2 | |
350 | 1,872 | |
- | 0.2% | |
4.8 | 6.8 | |
23 days ago | 4 months ago | |
Elixir | Elixir | |
Apache License 2.0 | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
mimic
-
An Introduction to Mocking Tools for Elixir
If you are used to Mocha for other languages, you can check out Mimic. It lets you define stubs and expectations during tests by keeping track of the stubbed module in an ETS table.
-
Purity injection in Elixir
By adjusting the mindset to stop thinking about dependencies and start to think about behaviours (functions) we were able to extract the impure parts of the number generator function. Then, by making them injectable we transformed the impure function to the one into which we can inject purity in tests, making it essentially pure and thus much easier to test. We also didn't need any fancy tool like Mox, Mimic or Rewire to define replacement modules for us. The code is hopefully understandable and uses only built-in Elixir idioms, without macros.
-
Testing in elixir
Check out https://github.com/edgurgel/mimic for mocking purposes
ex_machina
-
Test Data Libraries for Elixir
The factory library ExMachina created by Thoughbot uses function names and generates an atom used to call factories. For example:
-
How to write test cases for databse related functions
The well known FactoryBot (FactoryGirl) from rails has a pretty good equivalent in Phoenix as ExMachina (https://github.com/thoughtbot/ex_machina) and does the job really well (thoughtbot is a pretty good and stable contributor too, so a nice Omakase plug-in!)
What are some alternatives?
mox - Mocks and explicit contracts in Elixir
faker - Faker is a pure Elixir library for generating fake data.
mocha - Mocha is a mocking and stubbing library for Ruby
factory_girl_elixir - Minimal implementation of Ruby's factory_girl in Elixir.
plug_cowboy - Plug adapter for the Cowboy web server
blacksmith - Data generation framework for Elixir
ElixirMock - Creates clean, concurrent, inspectable mocks from elixir modules
FakerElixir - [unmaintained] FakerElixir generates fake data for you.
definject - Unobtrusive Dependency Injector for Elixir
espec - Elixir Behaviour Driven Development
bypass - Bypass provides a quick way to create a custom plug that can be put in place instead of an actual HTTP server to return prebaked responses to client requests.
espec_phoenix - ESpec for Phoenix web framework.