4 ms·
This is not a good practice because a unit test should be able to assume that no other code can possibly modify the data it is using. Later, another engineer co
by aisofteng 10y ago
This is not a good practice because a unit test should be able to assume that no other code can possibly modify the data it is using. Later, another engineer could possibly come in with the intent of modifying a single unit test in accordance with an isolated functional change in such a way that the data being used by other unit tests gets modified.
Then some poor fellow ends up redesigning the test suite to actually follow the assumptions of a unit test's test data being only ever accessed by that unit test. I have been that fellow, and it can be, bluntly, quite a pain in the ass; as you're doing it, you can't help but think, "whoever wrote this was too lazy to set up the test data properly, I shouldn't have to spend the time to fix this now."
- 88e282102ae2e5b 10y agoAh yes, I should have stated that the object is immutable.