Some Elixir testing Tricks

Open link in next tab

Some Elixir Testing Tricks

https://pdx.su/blog/2023-06-14-some-elixir-test-tricks

Testing in Elixir is pretty great. ExUnit, combined with the functional nature of Elixir, makes it very easy to test almost everything in your codebase. However, it is very easy for boilerplate to creep into your tests. Common setup patterns, similar assertions, and more can quickly make your test suite feel cumbersome. But ExUnit files are just Elixir files. So you can write bits of code that will help you out tremendously.

ExUnit is wonderful, and the functional paradigms that underpin Elixir let us write extremely complex tests in a fraction of the code that would be needed in OOP testing frameworks like RSpec.

But it's not all wine and roses. Tests can quickly accrue tons of boilerplate and repetition.

Using some Elixir features, you can cut down on these, and make tests even nicer to write.