Junit5: Introduce a TemporaryFolder extension

Created on 18 Jan 2018  路  14Comments  路  Source: junit-team/junit5

Overview

See discussion at https://github.com/junit-team/junit5-samples/issues/4.

Related Issues

  • #219

Deliverables

  • [X] ~Introduce an official TemporaryFolder extension for JUnit Jupiter analogous to the rule support in JUnit 4.~
Jupiter extensions programming model new feature

Most helpful comment

Team Decision: Add TempDirectory to junit-jupiter-api in package org.junit.jupiter.api.support.io and deprecate it in Pioneer.

All 14 comments

It would really been nice to have this feature available in the next release as it is still a deal-breaker in the complete migration to junit Jupiter.

This will be done in the half-official extensions project: junit-pioneer/junit-pioneer#39.

Still waiting on the first junit-pioneer release... :(

Only some more minutes...

There it is! Thank you! :pray:

Having TempDirectory be part of JUnit Pioneer has a few downsides:

  1. It requires knowledge of another dependency
  2. It requires management of another dependency version
  3. It has the unpleasant side effect of polluting the classpath with another @Test annotation

1 and 2 are only annoying when figuring out what JUnit 5's equivalent of TemporaryFolder might be. 3 is a constant annoyance when writing tests. That annoyance can be mitigated somewhat by everyone configuring their IDEs to avoid suggesting org.junitpioneer.vintage.Test.

Could the decision to move a core, and very useful, piece of JUnit 4 into a half-official extensions project please be reconsidered?

While such features are in experimental mode, having a dedicated dependency which only contains the extension would be helpful. This can then just be included additionally to the official Junit5 dependency.

Could the decision to move a core, and very useful, piece of JUnit 4 into a half-official extensions project please be reconsidered?

Hi @wilkinsona,

I'll bring it up with the team for renewed discussion.

Reopened and tentatively slated for 5.4 M1 for _team discussion_.

I agree with @wilkinsona, particularly regarding point 3. The extra @Test annotation is very confusing, and does not seem to provide any benefit. JUnit Jupiter provides better methods for dealing with expected exceptions and timeout of tests. I don't really see why org.junitpioneer.vintage.Test even exists.

Regarding the @Test in that library, I'd recommend opening a separate issue to https://github.com/junit-pioneer/junit-pioneer/issues.

Team Decision: Add TempDirectory to junit-jupiter-api in package org.junit.jupiter.api.support.io and deprecate it in Pioneer.

That's excellent news. Thank you for reconsidering.

Was this page helpful?
0 / 5 - 0 ratings