Classes structures look likes below:
class A {
protected String a;
protected String b;
A(String b1) {
new A("A111", b1);
}
A(String a1, String b1) {
a = a1;
b = b1;
}
}
class B extends A {
B(String b) {
super("A", b);
}
}
I need to write JUnit test case and needs to mock constructor for class A so that whenever object for class B needs to create then mock constructor for class A should get invoke and returns object from mock constructor.
I tried following :
new MockUp<A>() {
@Mock
public void $init(String b1) {
new A("A11111111", b1);
}
};
But object created in mocked constructor hasn't been returned.
Aucun commentaire:
Enregistrer un commentaire