5.5. Persistent temp files
The whole idea of a temporary file is to be temporary and be thrown away, deleted, after you’re done with it. What the persistent temp file test smell represents is the case when the temporary file isn’t that temporary but rather persistent, to the extent that it won’t be deleted before the next test runs.
As they say, assumption is the mother of all screw-ups, and we programmers tend to assume that temporary files are, well, temporary. This can lead to surprising behavior we’d rather avoid debugging. Indeed, you should try to avoid using files altogether where they are not essential to the objects you’re testing.
With that said, let’s dive into an example that explains the issue with persistent temporary files in more ...
Get Effective Unit Testing now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.