I recently ran into some code that forced me to integrate with a Java library. While using the library I found myself wanting to do a bit of interaction testing, which I’ve historically done with Mockito. As a result, I added the ability to do interaction based tests on mock Java objects, directly in expectations.
Hopefully the code is what you’d expect.
The previous example creates a mock Runnable in an expect-let, expects the
run method to be run, and then calls the run method of the mock. This test is worthless in a real world context, but it’s the simplest way to demonstrate the syntax for creating a mock & specifying the interaction.
Read more at the source