I'm testing 3 new classes that make 3 collections of objects that are serialized to a database. 1 of the classes has a hard coded array of strings. The 3 collections end up the same size as the array of strings and each object in the collection gets a name/tag based on string in the array.
One of my tests is an end-to-end test that will try to make all three collections. I would like to have access to the array of strings for testing but it's private. I see three possible ways to deal with this:
- Make it protected <- Office policy is to NOT modify code design for the sake of testing.
- Copy array to test class <- Now array changes must be maintained in two locations. Ow.
- Use reflection to peek at privates <- This works but is it more or less evil than the alternatives?
Can you think of a fourth way? Is there a good reason to not use reflection for this?