Sabir Khan
Sabir Khan

Reputation: 10132

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.

Upvotes: 3

Views: 1138

Answers (1)

Stephen C
Stephen C

Reputation: 718758

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

Upvotes: 2

Related Questions