I'm wondering if the use of third party software and/or network requests is the motivation for integration testing? For the sake of keeping the code examples minimal, I'll define a unit test as something that tests exactly one function, and an integration test as something that tests two or more functions.
I have in mind a progression like this:
- An application has only its own function (functions implemented in another module). Would it be fair to say that (short of not knowing how to mock the output of
my_first_funcEx1), a unit test on each of the two functions would make integration tests unnecessary in this case?:
# main c = my_first_funcEx1(a, b) d = my_second_funcEx1(c)
- An application uses third party software and/or network requests. Would it be fair to say that (short of doing three unit tests where one of them is on the second function shown below... assuming all relevant inputs/outputs can be mocked) that in this example, integration tests would be indicated where either the first and second function were put in the same integration test; the second and third were put in the same integration test; or all three were put in the same integration test? (Separately the first and third functions could have their own unit tests, but I'm trying to understand the motivation for integration tests in the simplest case):
# main l = my_first_funcEx2(j, k) m = third_party_function_call_or_network_request(l) n = my_second_funcEx2(m)