All quizzes
Free quiz · 20 questions in the bank

FactoryBot quiz

Test your FactoryBot knowledge with a free interactive quiz — 20 questions with answers and explanations. No signup needed to play.

Question 1/5Score 0

What is the difference between `FactoryBot.build(:user)` and `FactoryBot.create(:user)`?

Questions in this quiz
  1. What is the difference between `FactoryBot.build(:user)` and `FactoryBot.create(:user)`?
  2. Why might a team define multiple related factories with inheritance (e.g. `factory :admin_user, parent: :user do ... end`) rather than one large factory with many conditional branches?
  3. How is a basic FactoryBot factory typically defined?
  4. How does FactoryBot compare to Rails' built-in fixture files (YAML-based) as a way to generate test data?
  5. Why might overusing factory associations (auto-creating many related objects for every single test) become a performance concern in a large test suite?
  6. What is a benefit of using FactoryBot factories consistently across a test suite instead of manually instantiating model objects with `Model.new(...)` in every test?
  7. What does `FactoryBot.attributes_for(:user)` return, as distinct from `build` or `create`?
  8. Why might a test prefer `FactoryBot.build(:user)` over `FactoryBot.create(:user)` when persistence isn't actually needed?
  9. What is FactoryBot primarily used for?
  10. What is a FactoryBot "trait" used for?
  11. Why is it commonly recommended to keep factory-defined default attribute values minimal/valid rather than piling on excessive complexity?
  12. What does `FactoryBot.create_list(:user, 5)` do?
Gaps to close?
Read the curated FactoryBot notes — core concepts, patterns, interview prep.
FactoryBot notes

More quizzes

.NET.NET MAUIAbsintheAccessibilityActixActix Web