1

There used to be createInCustomDirectory() methods in TempDirectory extension class in JUnit 5.4.0-M1 (see docs). The main use case for those methods was to change tmp dir used by the extension. In the final release (5.4.0) TempDirectory extension was made private and enabled by default and those methods are not available anymore.

I wonder if there is another way to change root dir for all @TempDir directories?

Andrei Pechkurov
  • 438
  • 4
  • 10
  • 1
    An update for those who are interested in a workaround. You can override system property for temp dir when running tests in the following manner: `-Djava.io.tmpdir=/var/tmp`. As JUnit internally uses `java.nio.file.Files#createTempDirectory` internally, it'll do the trick. – Andrei Pechkurov Feb 12 '19 at 13:46
  • Very nice workaround! – Sam Brannen Feb 12 '19 at 13:51

1 Answers1

1

No, there is no way to customize the temp dir.

The scope of the @TempDir was reduced in JUnit 5.4 RC2. See the following issue for details: https://github.com/junit-team/junit5/issues/1752

Sam Brannen
  • 29,611
  • 5
  • 104
  • 136