Skip to content

Support added for JUnit's @TempDir#1387

Merged
msridhar merged 1 commit intouber:masterfrom
romainmoreau:junit-tempdir
Dec 21, 2025
Merged

Support added for JUnit's @TempDir#1387
msridhar merged 1 commit intouber:masterfrom
romainmoreau:junit-tempdir

Conversation

@romainmoreau
Copy link
Copy Markdown
Contributor

@romainmoreau romainmoreau commented Dec 20, 2025

This PR adds support for Junit @TempDir extension.

Summary by CodeRabbit

  • Chores

    • Updated JUnit 5 dependency to a newer version.
  • Tests

    • Added test coverage for JUnit 5 temporary directory annotation support.

✏️ Tip: You can customize this high-level summary in your review settings.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Dec 20, 2025

CLA assistant check
All committers have signed the CLA.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 20, 2025

Walkthrough

This pull request updates the JUnit 5 dependency from version 5.0.2 to 5.14.0 in the Gradle dependencies configuration. It adds the org.junit.jupiter.api.io.TempDir annotation to the set of excluded field annotations in the ErrorProneCLIFlagsConfig class. Additionally, a new test method junitTempDir() is introduced in the FrameworkTests class to verify JUnit 5 TempDir functionality with both static and instance field declarations.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main objective of the PR—adding support for JUnit's @tempdir annotation—and is clear and specific.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 81947cd and cdf0d81.

📒 Files selected for processing (3)
  • gradle/dependencies.gradle (1 hunks)
  • nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java (1 hunks)
  • nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-14T18:50:06.159Z
Learnt from: msridhar
Repo: uber/NullAway PR: 1245
File: guava-recent-unit-tests/src/test/java/com/uber/nullaway/guava/NullAwayGuavaParametricNullnessTests.java:101-102
Timestamp: 2025-08-14T18:50:06.159Z
Learning: In NullAway JSpecify tests, when JDK version requirements exist due to bytecode annotation reading capabilities, prefer failing tests over skipping them on unsupported versions to ensure CI catches regressions and enforces proper JDK version usage for developers.

Applied to files:

  • gradle/dependencies.gradle
  • nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java
  • nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java
🔇 Additional comments (3)
nullaway/src/main/java/com/uber/nullaway/ErrorProneCLIFlagsConfig.java (1)

186-187: LGTM! Correct addition of JUnit 5 @tempdir to excluded field annotations.

The addition of org.junit.jupiter.api.io.TempDir to the exclusion set is appropriate. Fields annotated with @TempDir are automatically initialized by JUnit's TempDirectory extension, so they should be excluded from NullAway's initialization checks, similar to dependency injection annotations like @Inject and @Autowired.

nullaway/src/test/java/com/uber/nullaway/FrameworkTests.java (1)

434-460: LGTM! Well-structured test for JUnit 5 @tempdir support.

The test correctly validates that NullAway properly handles @TempDir annotated fields:

  • Tests both static and instance fields (lines 446-449)
  • Covers different types supported by @TempDir (Path and File)
  • Verifies fields are accessible without null-safety errors in lifecycle methods (@BeforeAll, @test)

This aligns well with the configuration change in ErrorProneCLIFlagsConfig.java.

gradle/dependencies.gradle (1)

114-114: JUnit 5.14.0 is a valid and stable version. The version exists as an official release, and the upgrade is well-justified. @tempdir has been available since JUnit 5.4 and is stable in 5.14.0. The release includes improvements to test engine execution order, and fixes a regression affecting @nested test execution from 5.13.0. No breaking changes are documented that would impact typical test implementations.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Collaborator

@msridhar msridhar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

@msridhar msridhar enabled auto-merge (squash) December 20, 2025 23:57
@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 21, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 88.19%. Comparing base (81947cd) to head (cdf0d81).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1387   +/-   ##
=========================================
  Coverage     88.19%   88.19%           
  Complexity     2616     2616           
=========================================
  Files            95       95           
  Lines          8672     8672           
  Branches       1743     1743           
=========================================
  Hits           7648     7648           
  Misses          510      510           
  Partials        514      514           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@msridhar msridhar merged commit 6acbb64 into uber:master Dec 21, 2025
10 of 11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants