Is it good/bad practice to add more constructors just for test purposes (to mock the DOCs used in my SUT) like this :
public class A {
private B b = new B();
private C c = new C();
public A(){
}
/***
* used for test puproses
* @param a
* @param b
*/
A(A a, B b) {
// overwrite the existing variables
this.a = a;
this.b = b;
}
}
class B {
}
class C {
}
Note that i force the new constructor visibility to be package private not to pollute the SUT's api and also choose to instantiate the DOCs inside the SUT for client usage convenience.
SUT: System under test (A)
DOC: depended-on component (B and C)
What do you think ? Thanks in advance.