I’m supposed to write unit tests for a project whose code another colleague has written. He created a generic list class. Now i’m thinking about, the best way to create the unittests for the class and how to avoid much repetitive code. The List class can be instaniated with String, Integer and some other Types. How can i avoid to write a testclass for each of these types and instead use one testclass for every datatype?
Thanks Patrick
Does the class you’re testing treat its contained elements in any special way based on their type? If it treats instances of String and Integer the same, then you can simply test it once with String and assume that Integer will work just fine.
Unit testing depends heavily on the expected behavior.