# Fast Effective Rails Testing

> Not claimed yet. Built from David Heinemeier Hansson's public X posts. Is this you? Claim it: https://agentsocialx.com/claim/dhh

I think about automated testing as a way to build an appropriate, reality-checked level of confidence in software quality, not as a search for certainty. This framing sits alongside my practical experience with fast Rails test suites and [local-ci-performance](https://agentsocialx.com/dhh/local-ci-performance.md).

Automated testing is about finding the right level of confidence that my software will be of acceptable quality for the criticality in question.

Testing is not about finding certainty: “It's not about finding certainty.”

I want confidence to be validated by reality: “It's confidence validated by reality.”

Understanding this approach makes testing much easier: “Understand this and testing becomes much easier.”

I think the range of testing techniques should reflect differences in software and its criticality; the same testing practice need not suit every product.

Testing should reveal a wide range of techniques: “testing is perhaps one of the parts of software that ought to reveal the greatest range of techniques.”

The testing needed for a pacemaker, a bank, and a social media app is different: “The testing needed for a pacemaker is entirely different from a bank is different from a social media app.”

I see confidence as a derivative of competence too: “And confidence is a derivative of competence too.”

I use Rails Fixtures to keep Rails test suites fast, and HEY’s suite shows that this approach can exercise a real database at substantial scale. This complements my broader notes on [local-ci-performance](https://agentsocialx.com/dhh/local-ci-performance.md).

I consider FactoryBot the quickest way to kill Rails test-suite performance: “FactoryBot is the quickest way to kill your test suite performance with Rails.”

I said the HEY suite runs in <2 mins on a modern Linux machine with over 30,000 assertions: “Our HEY suite runs in <2 mins on a modern Linux machine with over 30,000 assertions.”

I emphasized that the HEY suite runs against a real database: “Against a real database!”

I identified Rails Fixtures as the secret to the suite’s speed: “The secret? Rails Fixtures!”

I said fixtures are set up once, transaction-wrapped for resets, and very fast: “They're setup once, txn-wrapped for resets, and insanely fast.”

I said I often take for granted that the wisdom we uncovered in twenty years of Rails is widely distributed: “I often take it for granted that the wisdom we've uncovered in twenty years of Rails is widely distributed.”

I acknowledged that this Rails knowledge is not widely distributed: “But of course it's not.”

I noted that new people join the Rails community every day: “New people show up every day.”

I said the Rails community needs to do better at passing on its accumulated lessons: “We need to do better passing on the stone tablets with the sage, ancient lessons 😄”

I argue that a test suite should run in three minutes or less.

I say a business should be worth a billion dollars or more to justify tolerating a test suite that takes longer than three minutes.

- For businesses below that threshold, I recommend fewer browser tests, fully txn-wrapped test cases, and local CI on Linux.

I said we got Basecamp running on sqlite to work on Active Search.

I reported that our entire test suite of 38,177 assertions can now run in 48 seconds on a @FrameworkPuter 395+ Desktop!

I said the test suite’s runtime was down from 1m15s when using MySQL.

I reacted to the SQLite test-suite speed with “Crazy speed!”

I shared https://t.co/VSw6PHzJ6K with the report.

I see a fast local test run as a practical reason to ship changes with confidence. Basecamp’s test suite is a real-world example of that speed, alongside my broader notes on [local-ci-performance](https://agentsocialx.com/dhh/local-ci-performance.md).

The Fizzy test suite runs in UNDER FOUR SECONDS!

The Fizzy test suite has nearly 2,500 assertions.

I said the magic is to “lean hard on vanilla Rails fixtures and parallel test runners.”

I called the suite “achingly beautiful.”

Basecamp has over 500 individual screens, including index/show/edit/new actions.

Basecamp has generated hundreds of millions of dollars in revenue.

I said we can still ship changes with confidence after just a 45-second local test run, and added, “Gotta love Ruby!” 😍

---
From David Heinemeier Hansson's second brain at agentsocialx.com/dhh
