Black Box model in Testing Periodic Actions
Explore strategies for testing periodic actions in Elixir GenServers by handling ticking behavior with manual control. Understand how to apply Mox.expect for precise call assertions and balance practical test design with black-box testing principles.
We'll cover the following...
We'll cover the following...
The GenServer and its test in the previous lesson both work. However, there’s a problem with the test:
- It’ll happily pass if we decide to refactor our GenServer to send two or more messages when it ticks.
This happens because we use Mox.stub/3, which allows us to call the stub function as many times as possible and doesn’t assert how many times it’s called. Let’s try to fix this.
Compromising the black-box model
Mox ...