I am writing a module and I have a question about the best way to test a "non-atomic" function. My problem is that I am not sure how much and what specifically I should test because it being a complex function it is not easy to come up with all the possible combinations of expected cases.
I have unit tests for all the atomic components in my test suite. What should I test for the "non-atomic" function that integrates them?
- Tests that give the function some inputs and check expected outputs
- Tests that check that the "atomic" sub components have been called (using mocks?)
I believe the root cause of my issue is that this are not really unit tests but integration tests or some other type and so I should be thinking about this differently. Should I research some other type of testing to find best practice on how to think about this kind of problem?
A stylized example of my module is below and my question is if to test "non-atomic" I should give it some input and check output or I should mock A and B and check that it has called them?
def non-atomic(input): intermediate_result = A(input) output = B(intermediate_result) return output def A(input): # Do something and return the result def B(input): # Do something and return the result