Automating Tests in Elixir Projects

using behaviours and implement a test module

Is that what I called Manual with Behaviours? Where you define a behaviour, and provide a real and a test implementation?

I like that too - it’s explicit and easy to reason about, with reasonable tradeoffs. Although it still raises the question of how you swap in the test module? I think the application environment is an oft-used mechanism, but I don’t find it especially simple or elegant… Curious if you’ve got another approach?

I share the instinct to keep things simple and avoid unnecessary dependencies. It’s a solid baseline. At the same time, I find that carefully chosen, narrow libraries are a big time-saver - they do one thing well and are easy to read and reason about. It’s always a tradeoff though.

On HTTP mocks vs real servers: I tend to see external test harnesses as more fitting for E2E tests. I haven’t covered that space yet in the blog, but definitely plan to. The focus so far is on unit tests, since they form the foundation of a testing strategy. That’s not to say they’re the only part. A test server like you describe sounds like a great fit when I get to that layer.

Testing is one of those areas with strong opinions and multiple valid approaches. My blog is more of a “random walk” than a “thorough search” through testing techniques - just things I’ve seen and tried in the wild. Always happy to hear how others are doing it so I can keep learning, if you feel like sharing?

1 Like