Let’s say there is a super-class
class SuperClass {
SuperClass(Foo foo) {
this.foo = foo;
}
SuperClass() {
this.foo = new DefaultFoo();
}
}
And there’s a sub-class
class SubClass extends SuperClass {
SubClass(Foo foo) {
super(foo);
}
}
The class under test is SubClass. I want to verify that SubClass' constructor is indeed invoking it’s superclass’ non-empty constructor. Is there any way to achieve this?
This should be possible with jmockit ( http://jmockit.googlecode.com ) by mocking superclass. Here is example
( from: https://groups.google.com/forum/?fromgroups=#!topic/jmockit-users/O-w9VJm4xOc )
}