I am looking for a solution / template for the next block testing.
Happening:
Suppose we have three classes, A, B, C each with one method. The method calls Method B, which calls Method C. So A-> B-> C. Each method accepts one input (input A for method A, input B, input C). The result of calling method A will be a tree structure, such as:
Root (created by method A) - Node B (created by method B) - Node C1 - Node C2 (both created from method C)
For me, unit testing is testing the output from the input of a method separately. So, we will write unit tests for each of the above methods. Since the tests are written in isolation, we will mock Method B when writing unit tests for Method A and mock Method C when writing unit test cases for Method B.
So far so good, we can write output expectations for each method to make sure that the resulting tree structure is respected.
Problem:
Now add another class that will call method B, so we will also have the following chain of calls: D-> B-> C. The resulting root tree will look like this:
- , A , :
, C, Node, . , .
D , - Node C1 Node C2.
:
, , D? , .
.