Refactoring to Increase Test Maintainability
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 allow our code to be 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. 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.
We want to make it clear that we don’t promote this style of testing wholesale across your application. We’re working in a section of our code that’s fairly predictable and limited ...
Get Testing Elixir now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.