-
Notifications
You must be signed in to change notification settings - Fork 13
Support nested classes in Maven plugin #1005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
""" WalkthroughThe changes introduce explicit handling for Java nested test classes in Maven test report processing. A new function replaces static file mask logic, allowing dynamic report file input and custom class name normalization by stripping Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant MavenTestRunner
participant PathBuilder
participant CommonRecordTestImpls
User->>CLI: launchable record tests <report files>
CLI->>MavenTestRunner: record_tests(client, reports)
MavenTestRunner->>PathBuilder: Override path_builder with junit5_nested_class_path_builder
MavenTestRunner->>CommonRecordTestImpls: load_report_files(client, reports)
CommonRecordTestImpls->>PathBuilder: Build normalized test paths (strip inner class names)
CommonRecordTestImpls-->>MavenTestRunner: Processed test data
MavenTestRunner-->>CLI: Complete recording
Poem
Note ⚡️ AI Code Reviews for VS Code, Cursor, WindsurfCodeRabbit now has a plugin for VS Code, Cursor and Windsurf. This brings AI code reviews directly in the code editor. Each commit is reviewed immediately, finding bugs before the PR is raised. Seamless context handoff to your AI code agent ensures that you can easily incorporate review feedback. 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (13)
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for nested classes in the Maven plugin by modifying how test class names containing '$' are handled, ensuring that inner class names are removed during test recording.
- Introduces a new test in tests/test_runners/test_maven.py for verifying nested class handling.
- Updates the Maven plugin logic in launchable/test_runners/maven.py to strip inner class identifiers.
- Adds a new test report (TEST-nested.xml) and updates the recorded test result (record_test_result.json) accordingly.
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/test_runners/test_maven.py | Added integration and unit tests for nested class logic |
| tests/data/maven/reports/TEST-nested.xml | New test report to simulate nested class output |
| tests/data/maven/record_test_result.json | Updated expected test results to reflect nested class fix |
| launchable/test_runners/maven.py | Updated logic to handle nested class names in test paths |
launchable/test_runners/maven.py
Outdated
| report_file: str) -> TestPath: | ||
| """ | ||
| With @Nested tests in JUnit 5, test class names have inner class names | ||
| like com.launchableinc.rocket_car_gradle.AppTest$InnerClass. |
Copilot
AI
May 22, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider updating the sample class name in the docstring to match the Maven context, e.g., 'com.launchableinc.rocket_car_maven.NestedTest$InnerClass', for clarity and consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
tests/test_runners/test_maven.py (1)
132-174: Comprehensive test for nested class name handlingThe test thoroughly covers both unit functionality and integration testing:
- It directly tests the path builder function that strips the
$suffix- It verifies the complete CLI workflow with the actual nested class test report
The test structure is clean and well-documented with a clear explanation of what's being tested.
One minor suggestion for future improvements:
- # Extract the implementation from maven.py directly - # This gets the implementation without going through the CLI/Click command + # Extract the core path builder logic for direct unit testing
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
launchable/test_runners/maven.py(2 hunks)tests/data/maven/record_test_result.json(1 hunks)tests/data/maven/reports/TEST-nested.xml(1 hunks)tests/test_runners/test_maven.py(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/test_runners/test_maven.py (1)
tests/cli_test_case.py (3)
CliTestCase(21-341)cli(200-211)assert_success(213-214)
⏰ Context from checks skipped due to timeout of 90000ms (13)
- GitHub Check: build (windows-latest, 3.6)
- GitHub Check: build (windows-latest, 3.12)
- GitHub Check: build (windows-latest, 3.11)
- GitHub Check: build (windows-latest, 3.10)
- GitHub Check: build (windows-latest, 3.9)
- GitHub Check: build (windows-latest, 3.8)
- GitHub Check: build (windows-latest, 3.7)
- GitHub Check: build (ubuntu-22.04, 3.12)
- GitHub Check: build (ubuntu-22.04, 3.11)
- GitHub Check: build (ubuntu-22.04, 3.10)
- GitHub Check: build (ubuntu-22.04, 3.9)
- GitHub Check: build (ubuntu-22.04, 3.8)
- GitHub Check: build (ubuntu-22.04, 3.7)
🔇 Additional comments (4)
tests/data/maven/reports/TEST-nested.xml (1)
1-4: Well-structured test data for nested class testingThis XML file correctly represents a Maven Surefire test report for a nested/inner class in Java, using the standard
$notation in the class name. The file will be useful for testing the new functionality.tests/data/maven/record_test_result.json (1)
21-38: Test data correctly represents the expected transformed outputThis new test case entry correctly shows how the nested class name should appear in the final output - with the
$InnerClasspart removed from the class name, leaving onlycom.launchableinc.rocket_car_maven.NestedTest. This aligns with the implementation goal of stripping inner class suffixes.launchable/test_runners/maven.py (2)
118-138: Well-implemented solution for handling nested class namesThe implementation correctly:
- Replaces the static file mask with dynamic report file input
- Overrides the path builder to strip inner class suffixes after
$- Provides thorough documentation explaining the rationale
This approach properly handles JUnit 5 nested test classes while maintaining backward compatibility.
9-9:Details
✅ Verification successful
Verify the relative import path change
The import path for
testpathhas changed from a relative import to a parent-level relative import. While this likely works in the current directory structure, verify that this change is intentional and doesn't indicate a deeper issue.
🏁 Script executed:
#!/bin/bash # Check the directory structure to confirm the import path is correct echo "Current directory structure:" find launchable -type d | sort echo "\nChecking for testpath.py location:" find launchable -name "testpath.py"Length of output: 428
Import path verified
The
from ..testpath import TestPathstatement inlaunchable/test_runners/maven.pycorrectly resolves tolaunchable/testpath.pybased on the current directory structure. No changes are needed.
|
LGTM but I will involve another member just in case. |
This comment has been minimized.
This comment has been minimized.
|
I found the test failure to be caused by Click's breaking change since v8.2. I'm going to fix this issue on another PR. |
|
To pass the test, I limited the Click version up to 8.1. I noted the issue #1006. |
launchable/test_runners/maven.py
Outdated
| def record_tests(client, reports): | ||
| default_path_builder = client.path_builder | ||
|
|
||
| def path_builder(case: TestCase, suite: TestSuite, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I did it on 2cbfa64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (3)
launchable/test_runners/gradle.py(2 hunks)launchable/test_runners/maven.py(2 hunks)launchable/utils/java.py(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- launchable/test_runners/maven.py
🧰 Additional context used
🧬 Code Graph Analysis (2)
launchable/test_runners/gradle.py (1)
launchable/utils/java.py (2)
junit5_nested_class_path_builder(35-56)path_builder(52-54)
launchable/utils/java.py (1)
launchable/test_runners/flutter.py (2)
TestCase(18-74)TestSuite(77-85)
🪛 GitHub Actions: Python package
launchable/utils/java.py
[error] 35-35: Function "builtins.callable" is not valid as a type. Perhaps you meant "typing.Callable" instead of "callable"? (valid-type)
[error] 53-53: Type error: 'callable?' is not callable. (misc)
🔇 Additional comments (5)
launchable/utils/java.py (3)
5-7: LGTM - Clean imports for the new functionality.The imports are correctly added to support the new utility function's type annotations and functionality.
36-51: Excellent documentation and clear purpose.The docstring clearly explains the problem being solved (JUnit 5 nested classes with
$syntax) and why this approach was chosen. The explanation about Launchable CLI's inability to detect inner classes during subsetting provides good context.
52-56:Details
✅ Verification successful
Logic looks correct but verify list comprehension assumptions.
The implementation correctly processes the test path by splitting class names at
$and taking only the outer class name. The logic preserves non-class items unchanged.However, please verify that
test_pathis always a list of dictionaries withtypeandnamekeys as expected.
🏁 Script executed:
#!/bin/bash # Description: Verify the structure of test_path objects returned by path builders # Expected: TestPath should be a list of dictionaries with 'type' and 'name' keys # Search for TestPath usage patterns and path_builder implementations ast-grep --pattern 'def $_(case: $_, suite: $_, report_file: $_) -> TestPath: $$$' # Search for TestPath type definition rg -A 10 "class TestPath\|TestPath.*=" # Search for existing path_builder usage rg -A 5 -B 5 "path_builder.*case.*suite"Length of output: 23282
Approve Java
path_builderlogicVerified that
default_path_builderconsistently returns aTestPath(i.e. aList[Dict]with"type"and"name"keys) across all runners, and the existing unit test intests/test_runners/test_maven.pyconfirms correct stripping of nested-class suffixes after$. No further changes required.🧰 Tools
🪛 GitHub Actions: Python package
[error] 53-53: Type error: 'callable?' is not callable. (misc)
launchable/test_runners/gradle.py (2)
6-6: LGTM - Clean import for the utility function.The import correctly brings in the new utility function from the Java utils module.
112-112: Excellent refactoring to use centralized logic.This change replaces the previously inline nested class handling with the centralized
junit5_nested_class_path_builderutility. This is exactly the type of code consolidation mentioned in the PR objectives where functionality from the Gradle plugin was copied to Maven, and now both can share the same implementation.The wrapper pattern preserves the existing behavior while adding nested class support.
|
Konboi
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM



In Junit5, nested classes are represented with
$likeOuterClass$InnerClass. One of our customers requested us to handle this case. I found we've already handled the case in the Gradle plugin. So, I copied the code to the Maven plugin and added a test case for it.Summary by CodeRabbit
clickpackage to ensure compatibility with Python versions above 3.6.