Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. testfixtures

testfixtures

MITGov3.19.0

A Go library for loading YAML fixtures into a real test database, inspired by Ruby on Rails.

Visit WebsiteGitHubGitHub
1.2k stars91 forks0 contributors

What is testfixtures?

testfixtures is a Go library that loads YAML-based test data into a real database before each test run, similar to Ruby on Rails' fixture system. It solves the problem of setting up consistent database states for functional tests, eliminating the need for complex mocks and ensuring tests reflect production behavior. By wiping and reloading data automatically, it provides a clean slate for every test case.

Target Audience

Go developers building database-backed applications who need reliable, repeatable functional tests. It's particularly useful for teams practicing test-driven development (TDD) or those migrating from Rails-like ecosystems.

Value Proposition

Developers choose testfixtures because it enables testing against real databases with minimal boilerplate, supports multiple SQL databases, and includes safety features to prevent accidental data loss. Its YAML format is human-readable, and the built-in dumper helps bootstrap fixtures from existing data.

Overview

Ruby on Rails like test fixtures for Go. Write tests against a real database

Use Cases

Best For

  • Writing integration tests for Go web applications with SQL databases
  • Migrating Ruby on Rails test suites to Go while keeping fixture workflows
  • Setting up complex relational data scenarios for functional testing
  • Ensuring test isolation by automatically cleaning database state
  • Bootstrapping test data from production or staging databases
  • Testing database-driven APIs with consistent seed data

Not Ideal For

  • Projects requiring parallel test execution without manual database isolation setup
  • Teams trying to generate fixtures from large production databases (the dumper is intended for small samples only)
  • Environments where PostgreSQL SUPERUSER access is unavailable for foreign key disabling
  • Applications using Google Spanner with complex interleaved table dependencies

Pros & Cons

Pros

Broad Database Support

Works with PostgreSQL, MySQL, SQLite, SQL Server, ClickHouse, and more via dialect configuration, making it versatile for multi-database projects.

Human-Readable Fixtures

Uses YAML files with automatic conversion for JSON, binary, and date/time columns, simplifying test data management without manual parsing.

Safety and Cleanup

Automatically wipes data and resets sequences, with checks like 'test' database name verification to prevent accidental production wipes.

Dynamic Data Generation

Supports Go templates with custom functions and delimiters for generating fixture data dynamically, useful for complex test scenarios.

Cons

PostgreSQL SUPERUSER Hassle

Default foreign key disabling requires SUPERUSER privileges, which can be a barrier in secure or managed environments unless using alternative methods like UseAlterConstraint.

Spanner Integration Complexity

For Google Spanner, interleaved tables require careful file ordering, and methods like Directory() are unsupported, adding setup overhead.

Performance Overhead

Reloading fixtures before each test can slow down test suites with large datasets, compared to mock-based or transaction-rollback approaches.

Frequently Asked Questions

Quick Stats

Stars1,233
Forks91
Contributors0
Open Issues11
Last commit13 days ago
CreatedSince 2016

Tags

#fixtures#database#yaml#integration-testing#database-testing#testing#functional-testing#database-cleanup#test-fixtures#go#sql

Built With

G
Go

Links & Resources

Website

Included in

Go169.1k
Auto-fetched 6 hours ago

Related Projects

TestifyTestify

A toolkit with common assertions and mocks that plays nicely with the standard library

Stars26,097
Forks1,799
Last commit2 days ago
KeployKeploy

Open-source platform for creating safe, isolated production sandboxes for API, integration, and E2E testing.

Stars18,341
Forks2,288
Last commit17 hours ago
GoConveyGoConvey

Go testing in the browser. Integrates with `go test`. Write behavioral tests in Go.

Stars8,415
Forks558
Last commit2 years ago
testcontainers-gotestcontainers-go

Testcontainers for Go is a Go package that makes it simple to create and clean up container-based dependencies for automated integration/smoke tests. The clean, easy-to-use API enables developers to programmatically define containers that should be run as part of a test and clean up those resources when the test is done.

Stars4,927
Forks623
Last commit6 days ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub