Performance: Fixture and factory usage
MEDIUM IMPACT
This affects test suite execution speed and memory usage during development and CI runs.
FactoryBot.define do
factory :user do
name { "Test User" }
email { "user@example.com" }
end
end
# Create only needed test data on demand with factoriesfixtures :users, :posts
# Tests rely on large YAML fixture files loaded before the suite runs| Pattern | Test Startup Time | Memory Usage | Test Execution Speed | Verdict |
|---|---|---|---|---|
| Large YAML Fixtures | High (loads all fixtures before tests) | High (all fixture data in memory) | Slower (due to memory pressure) | [X] Bad |
| On-demand Factories | Low (creates data per test) | Low (only needed data in memory) | Faster (less memory overhead) | [OK] Good |