Refactoring Tests for Added Safety

Learn how to add safety into the way we perform our tests.

Most applications that use Ecto have more than one schema, and over time each schema grows to have more fields or more logic in its changeset functions. We’re going to refactor our existing test file to make our code easier to maintain, but that means we’re going to tread into some territory that makes some folk uncomfortable: we’re going to refactor our tests to be self-updating.

Before we do that, we’ll build safety into the way we test to avoid a lot of the typical caveats that leave most people burned by writing self-updating tests.

Get hands-on with 1400+ tech skills courses.