I'm practicing Java.based TDD and write some piece of code, which reads and writes files. Now, I have about 100 tests for each scenario (read and write) to test my code, where I create a file or read a given file everytime. Files to write will be created in temporary directory and will be deleted after every test run. But this strategy produces a lot of I/O and I'm afraid in case of e.g. SSD lifetime. Mocking is not an option.
One possibility would be to reade/write a file once and then run my tests against a (static) data structure (pseudo code):
private static Object resultData = null;
@BeforeClass
// Read/Write my stuff here
resultData = ....
@Test
// Check my requirements
assertTrue(resultData....);
Problem is, that I can change expected behaviour inside test methods, so my tests are not autonomous anymore.
How would you deal with it?