Where does a test get its data, and when would you use SeeAllData?
Testing How firmly you rule out the shortcut. This is where a suite starts depending on one org.
The test creates it. By default a test cannot see the org's records, which
is deliberate — it means the suite behaves the same in a sandbox, in
production and in a scratch org. @isTest(SeeAllData=true) turns that off
and lets the test read real data, and I avoid it, because a test that
depends on a record somebody else can delete is a test that will fail for
reasons unrelated to the code.
I create it, ideally in a @TestSetup method so it is built once for the
class and rolled back between test methods. SeeAllData=true is a last
resort and the cases are narrow: something the test genuinely cannot
insert, which in practice means a handful of setup objects and occasionally
a pricebook. Even then I would rather find the supported way in — the
standard pricebook has Test.getStandardPricebookId() precisely so nobody
needs SeeAllData for it. The thing worth knowing is that isolation is not
total anyway: User, Profile, RecordType and some setup objects are
visible to tests regardless, so a test can still depend on org
configuration without ever asking for it.
They'll ask next What is the risk of a test factory everyone shares?
It becomes a dependency: a change to satisfy one test breaks twenty. Worth it anyway, but it needs the same care as production code.
They'll ask next Why does @TestSetup help?
One insert for the whole class instead of one per method, so the suite runs faster and each method still starts from the same clean state.