SeedFactory - a toolkit for test data generation

SeedFactory is a toolkit for test data generation.

The initial version was launched about a year ago. During this time, the library was tested in a real production project. And now, I’m happy to present it to the broader public :blush:
The current version is 0.5.0.

The main idea of SeedFactory is to generate data in tests according to your application business logic (read as context functions if you use Phoenix Contexts) whenever it is possible and avoid direct inserts to the database (as opposed to ex_machina).
This approach allows you to minimize testing of invalid states, as you’re not forced to keep complex database structure in your head in order to prepare test data.

The library is completely agnostic to the database toolkit.

The source code is available on GitHub. Check out Overview section in README file.
Please refer to docs for details.

Feel free to ask any questions!


This is great. I’ve tried a bunch of factory approaches, but this one feels quite well executed and seems to cover the needs I generally have quite well. I also really like that it makes it impossible to insert data in a way the codebase wouldn’t.

1 Like

That seems like super reasonable approach to factories. I already like that, however it feels a little bit macro heavy.

1 Like

Actually, command resolver can use whatever code you need. So, you can use something that differs from the actual implementation, like a simplified version of it. But the fact that it is placed in a single centralized place makes it very maintainable.

When I read your comment for the first time, I was surprised why do you think so, as there is only 1 macro – produce/1. Completely forgot that DSL for schema definition is built on macros :smile: That’s because the heavy lifting is done by spark (@zachdaniel thank you for the library, support and quick bug fixing!)

I tried to describe the schema using simple structures in my initial implementation. But eventually, current implementation won.