> ## Content Index
> Fetch the complete content index at: https://www.namastesalesforce.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# apex-test-factory
- URL: https://www.namastesalesforce.com/projects/apex-test-factory/
- Published: 2026-02-23T09:00:00.000Z
- Updated: 2026-02-23T09:00:00.000Z
- Description: Builder-pattern test data factory for Apex: sensible defaults, relationship wiring, bulk builders — tests that read like specifications.
- Author: Swarnil Singhai
- Tags: Apex, #project, #project-lang-apex, #project-stars-128, #Import 2026-09-03 19:13

Builder-pattern test data factory for Apex: sensible defaults, relationship wiring, bulk builders — tests that read like specifications.

## Why

Test setup is where Apex tests go to die: forty lines of record building before one line of behaviour. The factory gives every object a builder with working defaults, so a test states only what it cares about.

## Usage

Account acc = TF.account().withIndustry('Banking').insertRecord(); Contact c = TF.contact(acc).build(); — bulk variants (.list(200)) cover the governor-limit cases in one call.

## Design notes

Defaults live in one class per object, so an org's required-field quirks are handled exactly once. Nothing inserts unless you ask — pure-build tests stay database-free and fast.