0

What do you think about testing abstract classes and inheritance? For example we have abstract class "List", then "LinkedList" and "ArrayList" as subclasses. Should LinkedList and ArrayList be tested seperately of List class (should the test tests whole functionality of LinkedList or ArrayList), or should the tests be connected to the fact that we extend List class?

Testing whole functionality will cause code duplication, on the other hand I'm not very convinced of linking test of one class to it's implemmentation. I would imagine the situation in which I would like to stop to inherit LinkedList from List, and then if in tests we assume inheritence - we will have to delete tests. But they should stay to find out that my change is correct...

romsac
  • 13
  • 3
  • Possible duplicate: http://stackoverflow.com/questions/243274/best-practice-with-unit-testing-abstract-classes?rq=1 – bytedev Apr 15 '14 at 13:38
  • The best solution I guess it to create test class hierarchy. LinkedListTest would extend ListTest. ListTest would test all behaviour of "List" In LinkedListTest would be only specific test. That's how we will not have code duplications, and test full functionality.. – romsac Apr 18 '14 at 11:02

0 Answers0