Wrapping Up

Testing Elixir — by Andrea Leopardi, Jeffrey Matthias (45 / 80)

The Pragmatic Programmers
The Pragmatic Programmers

--

👈 Setting Up Sandbox Mode | TOC | Chapter 5 Testing Ecto Queries 👉

We’ve spent this chapter focusing on testing Ecto schemas. We used that topic as a way to visit case templates and helper functions, and we touched on the Ecto Sandbox. We also delved into building tests that either safely update themselves or let you know when your test file is out of sync with the schema definition, both of which reduce the work to maintain your test file.

In the next chapter, we’ll learn about testing queries and leveraging the factory pattern to speed up writing tests and make robust setup easier.

Footnotes

[28] https://hexdocs.pm/ecto/Ecto.Schema.html#module-reflection

[29] https://github.com/phoenixframework/phoenix/blob/cc261a67a83649555841b92c3cbc1df024888cc8/installer/templates/phx_ecto/data_case.ex#L48

[30] https://hexdocs.pm/ecto/3.4.4/Ecto.Changeset.html#//apple_ref/Function/apply_changes%2F1

[31] https://docs.docker.com/get-started/

[32] https://hexdocs.pm/ecto/Ecto.Schema.html#module-primitive-types

[33] https://hexdocs.pm/ecto/Ecto.Type.html

[34] https://github.com/elixir-ecto/ecto/blob/87ce8e3223a1c8a92d40536cf56ac83c0270d711/lib/ecto/changeset.ex#L2935

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.