factory_boy vs mixer
Python test data generation libraries compared
factory_boy and mixer both generate Python objects for tests as an alternative to hand-maintained fixtures. factory_boy centers on reusable factory definitions and build, create, or stub strategies, while mixer emphasizes generated field values and configurable backend persistence.

factory_boy: Create Python Test Data with Factories
factory_boy replaces static test fixtures with configurable factories that build Python objects for individual tests. It supports multiple creation strategies and integrations with popular ORMs, making it useful for projects that need flexible, repeatable test data.

mixer: Generate Test Data for Python Models
Mixer is a Python library for generating instances of Django, SQLAlchemy, Flask-SQLAlchemy, and other model types. It helps replace hand-written fixtures with generated test data, with controls for field values and database commits.
| factory_boy | mixer | |
|---|---|---|
| Language | Python | Python |
| License | MIT | — |
| Stars | 3.8k | 953 |
| Forks | 424 | 91 |
| Last analyzed | Oct 3, 2026 | Oct 24, 2026 |
Key differences
- factory_boy offers build, create, and stub strategies; mixer lets you configure whether generated objects are committed to a database.
- factory_boy documents ORM integrations for Django, Mogo, MongoEngine, and SQLAlchemy; mixer also lists Flask-SQLAlchemy, Peewee, Pony, and Marshmallow.
- factory_boy highlights subfactories, lazy attributes, sequences, and reseeding randomness; mixer highlights nested field values, custom value iterators, generator overrides, and Faker locale switching.
- factory_boy is listed with an MIT license; mixer metadata says NOASSERTION, while its README describes the project as BSD licensed.
- The supplied project facts list factory_boy at 3.8k stars and 424 forks, compared with mixer at 954 stars and 91 forks.
- mixer's considerations specify Python 3.7+ and Django 3.0 and 3.1 support; factory_boy's considerations refer readers to its documentation for compatibility details.
Choose factory_boy if you…
- need distinct build, saved-instance, and stub strategies.
- want reusable factory definitions with per-call overrides, related objects, and sequence-based values.
- need the listed Django, Mogo, MongoEngine, or SQLAlchemy integrations.
Choose mixer if you…
- want generated field values and configurable database commits.
- need the listed Flask-SQLAlchemy, Peewee, Pony, or Marshmallow support.
- want to customize field generators, register middleware, or switch Faker locales.
Compare the numbers side by side, or add more projects
This comparison is generated with AI from the OSRepos analyses of both projects. Always check each project's repository and documentation before choosing.