My app has two classes, FireWatcher and AlarmBell. When a fire starts, the watcher should ring the bell, with a level. For small fires, ring the bell with a small alarm level, for big fires, ring the bell like crazy.
class FireWatcher {
AlarmBell bell;
void onFire(int fireLevel) { bell.ring(2 * fireLevel); }
}
class AlarmBell {
void ring(int alarmLevel) { ... }
}
I want to test FireWatcher to make sure it calls method ring with the correct level. How can I do that with Mockito ?
I’d like something similar to the following, but cannot find anything in the documentation.
when(fireWatcher.onFire(1)).expect(mockAlarmBell.ring(2));
You need to pass in a mocked
AlarmBell.Example: