Skip to content

feat(LCHIB-779): Enhance JUnit5 nested class handling to correctly pr… - #1383

Merged
psakthivel04 merged 1 commit into
v1from
fix/v1-junit5-nested-displayname-classname
Sep 28, 2026
Merged

psakthivel04 merged 1 commit into
v1from
fix/v1-junit5-nested-displayname-classname

Conversation

@psakthivel04

@psakthivel04 psakthivel04 commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

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.

…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.
@psakthivel04
psakthivel04 merged commit 3ca9310 into v1 Sep 28, 2026
14 checks passed
@psakthivel04
psakthivel04 deleted the fix/v1-junit5-nested-displayname-classname branch September 28, 2026 07:44
This was referenced Sep 28, 2026
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.

2 participants