Comments by "p11" (@porky1118) on "When TDD is Difficult - Try This!" video.
-
9:15 I don't think, it's in general a good idea to remove file interactions from unit tests.
If it's just short strings or a few lines, sure. But if I really need to read in larger data formats, I don't want to add them into my code, but rather have them in separate files.
Else I might even mess up the format, I want to parse (for example when the parsed format and the language I use both support strings surrounded by quotes and escape characters, I can't just write the content of a file down).
I'd prefer to have them in real files. Maybe they could even inlined into the file at compile time and not really be read at runtime, but I don't think, this would make such a huge difference.
Besides I'm not sure if writing a file system abstaction, which can be used everywhere, where a normal file can be used, will not cause other problems and make some of the code far more complicated and maybe even less performant. Java is probably an exception, where this works well, and only, because the performance reducing features are activated by default (in this case virtual method inheritance).
2