Ericsson Interview Question
Developer Program EngineersTeam: ruby on rails
Country: India
Interview Type: Written Test
I agree that "Factories keep tests independent, while fixtures may not" is correct.
From the SaaS book:
A fixture is a fixed state used as a baseline for one or more tests. The term fixture comes from the manufacturing world: a test fixture is a device that holds or supports the item under test. Since all state in Rails SaaS apps is kept in the database, a fixture file defines a set of objects that is automatically loaded into the test database before tests are run, so you can use those objects in your tests without first setting them up.
Unless used carefully, fixtures can interfere with tests being Independent, as every test now depends implicitly on the fixture state, so changing the fixtures might change the behavior of tests. In addition, although each individual test probably relies on only one or two fixtures, the union of fixtures required by all tests can become unwieldy. For this reason, many programmers prefer to use a factory—a framework designed to allow quick creation of full-featured objects (rather than mocks) at testing time.
Factories create full-featured objects, but fixtures do not
- sam November 03, 2012