It's generally very important for tests to control their data, both to ensure reliability (reduce erratic failures and test pollution) but also to maximize expressiveness (the ability to cleanly exercise the behavior you want to observe).
In unit tests, this is normally a function of building clean APIs that require a minimal amount of arrangement.
The challenge increases as tests become more integrated. A number of issues become interesting:
Factories, Fixtures, and their drawbacks
Creating, managing, and loading test databases
Writing tests of remotely deployed systems, locally running systems in a separate process, and running systems in the same process
Controlling test data for integration points you don't own (e.g. third party APIs)
It's generally very important for tests to control their data, both to ensure reliability (reduce erratic failures and test pollution) but also to maximize expressiveness (the ability to cleanly exercise the behavior you want to observe).
In unit tests, this is normally a function of building clean APIs that require a minimal amount of arrangement.
The challenge increases as tests become more integrated. A number of issues become interesting: