Testing outgoing calls
In everyday practice, both incoming and outgoing calls happen between two separate, independent systems. This makes testing of incoming and outgoing calls a challenge with respect to controlling the flow of the tests. As shown in the previous section, Testing incoming calls, with incoming calls we can quasi switch between client-side and server-side while actually running our tests on one system. With outgoing calls, however, this is not possible as our application code – the client – is most likely calling upon an external system – the server – that we do not and cannot control and/or we do not want to interact with for whatever reason in our test context. In Chapter 12, Writing Testable Code, handling the interaction with an external system was mentioned as an example of why we should be writing testable code. Testable code should allow us to mimic the interaction and test the behavior of our application code given a controllable...