Skip to content

fix: detect JUnit 5 from submodule build files and default to JUnit 5#2063

Open
mashraf-222 wants to merge 1 commit intomainfrom
fix/junit5-multimodule-detection
Open

fix: detect JUnit 5 from submodule build files and default to JUnit 5#2063
mashraf-222 wants to merge 1 commit intomainfrom
fix/junit5-multimodule-detection

Conversation

@mashraf-222
Copy link
Copy Markdown
Contributor

Problem

Multi-module Gradle projects (OpenRewrite, Spring, etc.) were misdetected as JUnit 4 projects. The AI service then generated JUnit 4 tests that failed to compile because the project only has JUnit 5 dependencies.

Root Cause

_detect_test_deps_from_gradle() in config.py only checked the root build.gradle(.kts). For multi-module projects, the root build file typically only has plugin declarations — JUnit dependencies are in module-level build files.

Secondary: the default framework was junit4, which is wrong for the vast majority of modern Java projects.

Fix

  1. After checking the root build file, scan immediate child directories for build.gradle(.kts) files
  2. Changed the default framework from junit4 to junit5 (JUnit 5 has been the standard since 2017)

Test Coverage

  • 3 new tests in TestGradleSubmoduleDetection:
    • test_detect_gradle_junit5_from_submodule: Multi-module with junit-jupiter in submodule only
    • test_detect_gradle_junit5_from_root: Single-module with junit-jupiter in root (regression check)
    • test_default_to_junit5_when_nothing_detected: Empty project defaults to junit5

Testing

$ uv run pytest tests/test_languages/test_java/test_config.py::TestGradleSubmoduleDetection -v
3 passed

All 21 existing config tests still pass (18 existing + 3 new).

Multi-module Gradle projects declare JUnit 5 dependencies in submodule
build files, not the root. The detection function only checked the root
build.gradle, missing JUnit 5 entirely and falling back to JUnit 4.
Now scans immediate child directories for build files. Also changes the
default framework from JUnit 4 to JUnit 5 (standard since 2017).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

1 participant