Add Toaster in Phoenix LiveView application ThinkingElixir 104: Exploring Our Data with Chris Grainger

Avoid test setup pollution (and 4 problems it creates)

I’m not big fan of using shared setups in Elixir such as setup [:create_user]. I often feel that it adds more problems at the cost of a somewhat debatable convenience.

For example, it sometimes creates unused data or introduces mystery guests, or the data created needs to be updated anyway. Or it simply obscures the test by separating the context in which the test runs from the exercise and verification.

I wrote a bit about that in a post.

https://www.germanvelasco.com/blog/avoid-test-setup-pollution-and-four-problems-it-creates