Skip to content

@TempDir directories of successful tests are not cleaned with ON_SUCCESS mode #4464

Closed
@msulima

Description

@msulima

In our test suite we’ve noticed that if any test fails (for whatever reason), then a lot of subsequent tests fail due to out-of-disk problems. This disk space is taken by temporary JUnit directories (org.junit.jupiter.api.io.TempDir). We use junit.jupiter.tempdir.cleanup.mode.default=ON_SUCCESS property, so theoretically only directories for failed tests should be preserved, but we also see many directories for successful ones.

Expected behavior

All temporary directories of successful tests should be deleted. It worked this way in 5.10.0.

Actual behavior

If one test fails, then temporary directories of subsequent successful tests are preserved. First observed in 5.10.1.

I think it was introduced in #3510 . Looks like selfOrChildFailed starts treating all subsequent tests as failed.

Steps to reproduce

I’ve put a minimal reproducible example in this repository: https://github.com/msulima/junit-tmpdir-cleanup

Context

  • JUnit: 5.10.1, 5.11.0, 5.12.1
  • Maven 3.9.9 + surefire 3.3.0

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions