I'm writing unit tests for classes which have properties that have setters but no getters.
I want to be able to test these setters to make sure they are setting the data correctly.
I find my options are:
- write getters for these functions so that I can test if they are set correctly
- write a method such as
testAllSetters()which test them all at once
But both solutions are undesirable since it adds unneeded functionality to the class just for the sake of testing it.
- I could also test the output of the class to see that it is correct in general, but in many cases this doesn't test the individual setters as I would like
What is the best way to unit test setters on classes that do not have paired getters?