Best practice Unit testing abstract classes?

Posted by Paul Whelan on Stack Overflow See other posts from Stack Overflow or by Paul Whelan
Published on 2008-10-28T13:25:21Z Indexed on 2010/06/01 7:03 UTC
Read the original article Hit count: 338

Hello

I was wondering what the best practice is for unit testing abstract classes and classes that extend abstract classes.

Should I test the abstract class by extending it and stubbing out the abstract methods and then test all the concrete methods? Then only test the methods I override and the abstract methods in the unit tests for objects that extend my abstract class.

Should I have an abstract test case that can be used to test the methods of the abstract class and extend this class in my test case for objects that extend the abstract class?

EDIT: My abstract class has some concrete methods.

I would be interested to see what people are using.

Thanks Paul

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about unit-testing