Skip to content
This repository has been archived by the owner on Feb 13, 2020. It is now read-only.

Data Factory

epall edited this page Apr 29, 2011 · 1 revision

Tests that use hard-coded data tend to be brittle and difficult to parallelize. Depending on static fixtures is an easy crutch to get started, but it will burn you eventually. It's better to randomize test data from the start, which allows your tests to run independently of each other.

Test::Right provides the DataFactory to solve this. In your tests, you can use data[:foo] instead of "foo" anywhere you need a string, and each time you'll get a new, unique string. Use this same identifier throughout an individual test to consistently identify your widgets, then throw it away when the test is finished.

Clone this wiki locally