July 2017
Intermediate to advanced
284 pages
6h 45m
English
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.
| | ~~~ |
| | # person.csv |
| | first_name, last_name |
| | Paul, Revere |
| | ~~~ |
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: ...
Read now
Unlock full access