---
title: "Database testing with fixtures and seeding"
description: "Seeding and fixtures solve different problems when populating databases for testing."
url: "https://swe.quest/articles/database-testing-with-fixtures-and-seeding-c9148078cf139feb"
canonical: "https://neon.com/blog/database-testing-with-fixtures-and-seeding"
source: "Neon"
published: "2024-07-02"
difficulty: "medium"
kind: "How-to"
reading_minutes: 9
tags: ["testing","databases","python","ruby"]
---

# Database testing with fixtures and seeding

A post on [Neon](https://swe.quest/sources/neon.md), published 2024-07-02, 9 min read, How-to. Original: [https://neon.com/blog/database-testing-with-fixtures-and-seeding](https://neon.com/blog/database-testing-with-fixtures-and-seeding)

## Summary

Seeding and fixtures solve different problems when populating databases for testing. Static seeds load fixed, version-controlled, idempotent reference data an app needs to run (admin users, countries and states), shown with Django scripts and Rails \`db:seed\`. Dynamic seeds generated with Faker supply large or randomized datasets for load and edge-case testing. Fixtures are framework-integrated, per-test datasets (e.g. Django YAML fixtures loaded in TestCase) that are set up and torn down around each test. Neon's database branching is pitched as a complement for isolated, resettable test environments.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Testing](https://swe.quest/tags/testing.md) (Engineering practices)
- [Databases](https://swe.quest/tags/databases.md) (Data & databases)
- [Python](https://swe.quest/tags/python.md) (Languages)
- [Ruby](https://swe.quest/tags/ruby.md) (Languages)

## Prerequisites

- ORM basics
- unit testing frameworks ([easy posts on Testing](https://swe.quest/tags/testing.md?difficulty=easy))

## Keywords

Django, Ruby on Rails, Faker, Neon, database branching

## Related posts

- [How To Maintain Seed Files (And Why You May Not Want To Do It)](https://swe.quest/articles/how-to-maintain-seed-files-and-why-you-may-not-want-to-do-it-8f196f8d27fea45b.md): Neon · 2025-02-05 · Medium · 7 min read · Databases, Testing, PostgreSQL, Ruby, Developer productivity
  Seed files should be versioned alongside schema changes, executed automatically in pipelines, split by environment, made incremental like migrations, and written to be idempotent, with Ruby/Rails and Docker Compose examples showing each practice.
- [Test Your Database Without Mocks](https://swe.quest/articles/test-your-database-without-mocks-093131d18e46824a.md): Neon · 2025-01-15 · Medium · 7 min read · Testing, PostgreSQL, CI/CD
  Database mocks are brittle, expensive to maintain, and test little beyond the mock itself, since they skip real behaviour like transactions, isolation levels, foreign keys and referential integrity.
- [Postgres for Ephemeral Environments: A Method to Keep Data Persistent](https://swe.quest/articles/postgres-for-ephemeral-environments-a-method-to-keep-data-persistent-5ef8547c6782b2cb.md): Neon · 2025-01-07 · Easy · 7 min read · PostgreSQL, Deployment, CI/CD, Testing
  Neon branches, which are copy-on-write clones of a Postgres database, can provide pre-seeded databases for ephemeral PR environments.
- [Stop Mocking Auth (It’s Breaking Your Tests)](https://swe.quest/articles/stop-mocking-auth-it-s-breaking-your-tests-f37ca9cbb9aaf394.md): Neon · 2025-12-29 · Medium · 8 min read · Testing, Identity & auth, PostgreSQL, CI/CD
  Mocking authentication in tests hides real failures: password hashing and verification, UNIQUE-constraint enforcement under concurrent signups, session handling, and SQL joins between auth and application data.
- [Neon Testing: a Vitest Library for Your Integration Tests](https://swe.quest/articles/neon-testing-a-vitest-library-for-your-integration-tests-fb19e0ca01596389.md): Neon · 2025-09-09 · Medium · 3 min read · Testing, PostgreSQL, TypeScript
  Neon Testing is an open-source Vitest utility that automates creating and tearing down Neon Postgres branches so each test file runs integration tests against its own isolated, schema-accurate database.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
