The end result of the unit of work is returning a value. The test will verify the value that is returned from a method.
The end result of the unit of work is changing the state of the system. The test will verify the behavior changes in the system under test after changing its state.
The end result of the unit of work is a call to a third-party object that is not under the control of the test or not part of the unit of work under test. The test will verify if the object calls other objects correctly.
Interaction test is usually the last option. It can result in unmaintainable and unreadable test code, if done badly.
Interaction unit tests can test the interaction between objects using mock objects. The mock object verifies if the object under test called the mock object as expected.
Resource for this article
- The Art of Unit Testing, Roy Osherove
- Growing object-oriented software, guided by tests, Steve Freeman and Nat Pryce
- The London school of TDD
- xUnit test patterns: refactoring test code, Gerard Meszaros
- Test Spy