Repository navigation
feat(LCHIB-779): Enhance JUnit5 nested class handling to correctly pr… - #1383
Merged
Merged
Conversation
…ocess @DisplayName attributes (v1) Port of the main-branch fix (PR #1382) to v1/launchable. When a JUnit5 @nested class has an explicit @DisplayName, Surefire (>= ~3.5.x) drops the outer class name from `classname` entirely and reports only the display name (e.g. classname="addFollowList", no dot, no $). junit5_nested_class_path_builder now falls back to the enclosing <testsuite name="..."> attribute (always the outer class FQCN) when classname has no dot, before applying the existing $-suffix stripping.
Konboi
approved these changes
Sep 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Customer (org line, workspace news-cmt-api-comment-unit-test) reported "Too many classes included in the subset output were not recorded" — 17 out of 196 classes. Root-caused and reproduced against the customer's exact pom.xml (Surefire 3.5.6, no special report config):
When a JUnit5 @nested class carries an explicit @DisplayName, Surefire (≥ ~3.5.x) drops the outer class's fully-qualified name from the classname attribute entirely and reports just the bare @DisplayName value:
junit5_nested_class_path_builder already handled the sibling case — @nested classes without a @DisplayName, where Surefire keeps Outer$Inner and we strip the $ suffix — but had no fallback for a classname with no dot at all. As a result these tests get recorded under class=addFollowList instead of the real class, so later subset requests (which always send the real FQCN) never match, and the class shows up as "not recorded" even though it ran.
Confirmed against production: 176 distinct bare-classname values across one session's test_cases, matching this exact pattern.
What
smart_tests/utils/java.py: junit5_nested_class_path_builder now falls back to the enclosing attribute (always the outer class FQCN) when the reported classname has no . in it, before applying the existing $-suffix stripping. Both maven.py and gradle.py pick this up automatically since they share this function.
tests/test_runners/test_maven.py: replaced a test that asserted against a hand-copied duplicate of the old logic (never actually exercised the real function) with:
two direct unit tests against the real junit5_nested_class_path_builder, using real junitparser-parsed XML for both the $-suffix case and the new bare-displayname case
an end-to-end CLI test asserting the exact JSON payload submitted for the bare-displayname fixture
New fixture tests/data/maven/reports-nested-displayname/TEST-nested-displayname.xml reproducing the bug shape, kept in its own directory so it doesn't get swept into the existing glob-based test_record_test_maven test.
New golden file tests/data/maven/record_test_nested_displayname_result.json for the E2E assertion.