When initially developing tests against legacy code that utilizes the filesystem extensively, I often find myself creating using @TempDir, which is fantastic. But oftentimes when debugging and/or initially writing the test I need to capture the outputs to get a "golden file" that I can regression test against on future runs. As such, currently I just use a non-TempDir folder to capture them, then need to update my test using TempDir later.
It would be super helpful if instead the TempDir annotation provided an option so that I could disable cleanup for a couple of runs then re-enable cleanup later in the development lifecycle. I'm envisioning something like the following
@TempDir(cleanup=false)
private Path outputFolder;
Tentatively slated for 5.7 M1 solely for the purpose of _team discussion_
I think a system property might be useful as well.
Team decision: Let's add a "strategy-like" config parameter (similar to display name generator or method orderer) to configure in which cases temp dirs should be cleaned up with initial implementations of "always", "on_success", and "never". This needs to be spec'ed out a bit more before work can actually be started.
In addition, we could add a new class-level @TempDirCleanupStrategy or @TempDirCleanupMode annotation to configure it per class.
Most helpful comment
Team decision: Let's add a "strategy-like" config parameter (similar to display name generator or method orderer) to configure in which cases temp dirs should be cleaned up with initial implementations of "always", "on_success", and "never". This needs to be spec'ed out a bit more before work can actually be started.