...
/Black Box model in Testing Periodic Actions
Black Box model in Testing Periodic Actions
Learn how to control the GenServer manually and assert how many times the stub function is called.
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 provides the perfect function for what we want: Mox.expect/4
...