It would be best to reorganize your methods to work with input / output streams, rather than with files directly. That way, you can easily pass StringReaders / Writers to them in unit tests (assuming they work with text files - if not, you need the appropriate threads).
If you work directly with files, your hardware tests become more complicated, because for creating and cleaning the test directory, as well as for reading / writing files in each test, an additional setup / break code is required, which slows down the tests. In addition, this opens up opportunities for problems such as a lack of write permissions in a specific directory (for example, because it was created in a test run launched by another developer), a complete disk error, etc. It’s best to do your unit tests yourself - as much as possible.
Péter Török
source share