RFR: 7903953: Use scratch directory for JUnit's TempDir annotation [v2]

Christian Stein cstein at openjdk.org
Tue Feb 25 07:48:06 UTC 2025


On Tue, 25 Feb 2025 07:28:45 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> Perhaps it would be better to replace this non-obvious declarative guard with a programmatic `Assumptions....` statement within the test method. 🤔
>
>> The assertion(s) in the test only make sense, when jtreg runs the test via its JUnitRunner.
> 
> Since this is a self test in the jtreg project, would it be the case that a test marked as `@run junit` will always be run by the `JUnitRunner`? So even the assumption I think is probably isn't needed.

When running this self-test without jtreg in play, for example via a direct launch within an IDE(A), it would fail hard. With the assumption in place, developers see:


org.opentest4j.TestAbortedException: Assumption failed: jtreg not running

	at org.junit.jupiter.api.Assumptions.throwAssumptionFailed(Assumptions.java:316)
	at org.junit.jupiter.api.Assumptions.assumeTrue(Assumptions.java:115)
	at JupiterTempDir.currentWorkingDirectoryIsParentOfTemporary(JupiterTempDir.java:44)


Adding a comment, as suggested in another channel, will help future folk though.

-------------

PR Review Comment: https://git.openjdk.org/jtreg/pull/248#discussion_r1969159540


More information about the jtreg-dev mailing list