I’m trying to write unit tests for a method that takes a String filename, then opens the file and reads from it. So, to test that method, I thought about writing a file, then calling my method. However, in the build farm, it is not possible to write files arbitrarily to disk. Is there a standard way to “simulate” having a real file in my unit test?
Share
This is highly frowned upon:
Source
If you must read from a file, have a test file pre-generated that all unit tests read from. There is no need to write anything to disk.