Getting Started with Testing Data

Learn about test data, fixtures performance, and factories performance.

Test data

Creating test data sounds like it should be the easiest thing ever. We already have ActiveRecord#create. We might ask ourselves, isn’t that enough? Not quite. To be useful, the data we generate for the tests needs to support the goals of testing. We should be able to create the data quickly and easily, both in the amount of typing it takes to create data and the speed at which the test runs. The data should be the same every time we generate it, specific to a set of tests, and accurately represent the objects used when the code runs outside of tests.

Get hands-on with 1200+ tech skills courses.