JUnit Jupiter supports a @TempDir Path annotation to "create and clean up a temporary directory for an individual test or all tests in a test class."
By default, those directories are created in the "java.io.tmpdir" folder; which is left as-is by jtreg when running tests. Therefore, tests using the JUnit @TempDir annotation experience decoupled temporary files from jtreg's scratch directories:
3.5 What is a scratch directory? [https://openjdk.org/jtreg/faq.html#scratch-directory]
When jtreg executes a test, the current directory for the test is set to a scratch directory so that the test can easily write any temporary files. jtreg will ensure that the directory is always empty when the test begins, so that the test does not have to worry about deleting any pre-existing files. These directories are placed in the work directory.
In jtreg 7.6 we should streamline JUnit's standard temporary directory factory to make use of this default behaviour.
By default, those directories are created in the "java.io.tmpdir" folder; which is left as-is by jtreg when running tests. Therefore, tests using the JUnit @TempDir annotation experience decoupled temporary files from jtreg's scratch directories:
3.5 What is a scratch directory? [https://openjdk.org/jtreg/faq.html#scratch-directory]
When jtreg executes a test, the current directory for the test is set to a scratch directory so that the test can easily write any temporary files. jtreg will ensure that the directory is always empty when the test begins, so that the test does not have to worry about deleting any pre-existing files. These directories are placed in the work directory.
In jtreg 7.6 we should streamline JUnit's standard temporary directory factory to make use of this default behaviour.
- links to
-
Commit(master) openjdk/jtreg/759946de
-
Review(master) openjdk/jtreg/248