Behaviour-Driven Unit Testing for Phoenix Controllers ↦
This is a great introduction to the Mox library written by José Valim and the Plataformatec team. Mox’ philosophy:
A simple summary is that when it comes to dependency injection, mocks should not be created ad-hoc. Instead, they should be constrained by predefined behaviours. This helps enforce contracts between modules, and it also makes tests easier to maintain and understand.
We’ve been using the Mock library when testing against 3rd party services, and it works as advertised. However, we don’t test our controllers in isolation like in this post. Should we be?
Sign in or Join to comment or subscribe