I'm new to unit testing and I'm trying to test tree like structure like so:
A
|
B
/ \
C D
I have written unit tests for C and D using JUnit4, and now I want to test B. Is there a smart way of doing this which doesn't require me to replicate all the code that sets up C and D?
I basically want to first run the tests for C and D, then with those data structures loaded, run the test for B, and then run the test for A, all in one go without any tearing down.
How would I go about for setting this up in JUnit4?