← Graph

Build vs Create in Tests

concept 2 connections

Heuristic for factory-based test suites: pick the cheapest factory method that still satisfies the test. Use build_stubbed when you need a dependency object you won't interact with; build when you need an in-memory object and no DB interaction; create without associations when a DB row is required but related records aren't; full create only for genuine end-to-end or request tests. test-prof can automatically replace every create with build and log the tests that then fail so they can be rolled back to create selectively.

category
practice
about
Build vs Create in Tests concept
Walks through build_stubbed / build / create-without-associations / create as a cost hierarchy.
about
Build vs Create in Tests concept
Question is about applying the build-over-create approach on callback-heavy codebases.

Provenance

Read by
4 extractions