Hi,
I have a set of classes that have dependencies at instantiation time, that is, when creating an object of type A, it also creates another of type B, which subsequently creates others of type C, etc.
For testing matters, I don't need the whole functionality of all the levels to test the upper ones, so I could use stubs or mocks, but as I have explicit new
's in the constructors I cannot see a direct way other than changing the code to use an AbstractFactory and provide one that creates the fakes at testing time.
So, is there any "black magic" way to hack the Java class loader so the fake testing classes are created instead the normal ones when instantiating objects with new
?
Thanks!