Are there any generally used alternatives to ExMachina for setting up a bunch of entities for a test? It’s not that ExMachina is bad, I just feel like there is room for another approach to setting up entities for testing purposes.
Honestly I feel like a lot of the motivating factors these kinds of libraries were built for no longer apply with Ecto 2.1. The sandbox means that you don’t have to worry about conflicting unique constraints, and it also makes it super easy to create nested layers of schemas all at once. The Ecto book has some good examples of both.
I used Blacksmith back in the day, then switched to ExMachina, but I’m slowly phasing it out and just using some occasional helper functions and Ecto features.
@benwilson512 Yeah that makes a lot of sense. For my latest application I’m going to try to avoid using ExMachina and just build up the entities (models?) as needed and insert them directly with Ecto. Maybe I’ll end up with a suite of helper functions. Especially since I’m using an umbrella app setup.
Check out the free ebook “What’s new in Ecto 2.1” [1] - there’s a chapter about exactly writing factory using just Ecto API.
[1] http://pages.plataformatec.com.br/ebook-whats-new-in-ecto-2-0