apex-test-factory

Public
On this page

    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.