I'm not sure about specific frameworks, but the general approach from the OOP point of view is to write some abstract layers on top of any file access code (interfaces are plentiful!) And possibly a facade to facilitate the use of common operations. then you are simply mocking one layer below the code that you are testing now, and then essentially a fake file system (or at least the code that you are testing will not know otherwise).
If you learn to use the dependency framework to handle this for you, it will make it easier to switch components for a fake interface implementation. if you follow the control inversion patterns, passing any dependencies to the constructor of the class you are testing will also make testing easier.
public interface IFileSystem { IFileHandle Load(string path);
I hope that my java is correct, I have not written java for a long time, but you hopefully get a drift. hope i don't underestimate the problem here and oversimplified!
Of course, all this assumes that you mean true unit testing, that is, testing the smallest possible units of code, and not the entire system. integration testing requires a different approach.
WickyNilliams Aug 07 2018-11-11T00: 00Z
source share