So I have three classes: A, B, C. I need to write unit tests for class A.
class A extends B{
//fields go here ...
public A(String string, ...){
super.(string,...);
}
//other methods here ...
}
class B{
C stuff;
//other stuff
}
So C is an important resource (like JDBC or ssh Session). Naturally, I am mocking C. How do I mock B. Imagine B has many children classes that extends it.
My main problem is that A is calling super.(...). I don't want to inject methods into A just for testing. To me that's bad design. Any ideas how to mock the parent?
For example I cannot do class MockB extends B{...} and then try MockB obj = new A(); This would not work because both MockB and A would be children of B.