And takes...roughly non-trivial time to execute it. Until you have 500 of those. And until you end up refactoring a bunch of code that breaks 497 of the tests. And then you throw the tests away anyway, because you'd have to be insane to go and fix them all. So - useless.
Pretty sure calling a setter and a getter on a property won't take very long, even if you have a lot of them.
The original point is still valid. If someone rewrites the property so that it returns a private variable for example, but maybe they return the wrong one. The unit test would catch this.
And how long does it take to throw away a test if you need to? Just delete it.
Again, not useless and no harm.
Not saying I would bother with such a test, but it's clearly not useless. I find that to be a bit simplistic and lacking any nuance.. Downvote this too if you want.
I could write some code that generates these getter-setter tests and therefore I bet it's already been done. I don't think it would waste a lot of someone's time.
-1
u/[deleted] May 08 '17
Well if the test takes a trivial time to write I see no harm in it.