I would expect subclass always call super() for some method.
How can I enforce or at least give a warning at compile time?
Thanks
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I think that Chris White‘s answer is best in the general case. But chen ying’s comment “I know enforcing to call super is not good. But I did not own the super class. And SDK documentation requires to call super. for example link” suggests that it is not suitable in this particular instance.
I would thus suggest modifying Chris White’s answer to meet the particulars.
Then if a subclass is under your control make it a subclass of ChenYingTestCase. If the subclass is not under you control, well you can’t really force it to call super().