O'Reilly logo

Functional Programming: A PragPub Anthology by Michael Swaine

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Typical Approaches

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required