Search code examples
javaunit-testingjunitjmockit

In unit tests, do we test Super classes too?


I have a situation where class under test has a method which does return super.delete(obj); so while writing unit tests with Junit & Jmockit, should I mock return value of return super.delete(obj); or keep going up above the hierarchy? Actually, this super call keeps going up to three four levels in inheritance hierarchy. I am just confused if it still remains a unit test if I step into super classes.


Solution

  • You should not mock that call. The superclass behavior is (should be) part of the behavior under test when you test a subclass.