Most typical test cases use one of a handful of approaches.
Explicit: an application can simply explicitly generate test data, leading to code that looks like this:
|||Person.create first_name: "Paul", last_name: "Revere"|
The downside is that such code will get awkward once you’re creating enough entities with enough attributes. In short order, the data overwhelms the test.
Through Fixtures: an application can create test data in tabular form, and then load all of that data into the application.
This strategy works all right, but leads to code that is hard to maintain as applications grow, because foreign keys are difficult to manage.
Through templates: ...