Skip to content

Keep JUnit output when test groups are interleaved - #1894

Open
Angel2Eyes wants to merge 1 commit into
cpputest:masterfrom
Angel2Eyes:fix/junit-keep-groups-across-interleave
Open

Angel2Eyes wants to merge 1 commit into
cpputest:masterfrom
Angel2Eyes:fix/junit-keep-groups-across-interleave

Conversation

@Angel2Eyes

@Angel2Eyes Angel2Eyes commented Sep 6, 2026

Copy link
Copy Markdown

Summary

  • Keep one in-memory bucket per test group in -ojunit output so a later visit to the same group no longer truncates earlier tests.
  • Snapshot each test's assertion count when the test ends, so interleaved groups still report the right assertions= values.

Problem

JUnitTestOutput buffers a single group and opens cpputest_<group>.xml with mode "w" at every group-end. TestRegistry::endOfGroup treats a name change as the end of a group, so interleaved tests or -s shuffle causes the reporter to throw away the first visit and overwrite the file with only the last fragment.

Problem reported in #1790, #1741, #168, and #1207.

Fix

Keep a linked list of groups (no STL). On each test, append to that group's bucket even if we left it earlier. On group-end, still write the file immediately, but write the full accumulated list. Store the per-test assertion delta at test-end so a rewrite of group A after running group B does not steal B's checks.

Sequential groups produce the same XML shape as before. The JUnit test helper no longer double-runs the last test on a group switch; that only became visible once the reporter stopped wiping the buffer.

Verification

  • New tests for interleaved groups: all tests present, failures from the first visit kept, assertion counts not mixed across groups.
  • Existing JUnitOutputTest cases still pass, including sequential groups and testFailuresInSeparateGroups.
  • CMake/CTest RelWithDebInfo on MSVC: 84/84 passed.

-ojunit rewrote each group file from a single in-memory
buffer, so a later visit dropped earlier tests. Keep one
bucket per group and snapshot assertion counts when the
test ends.

Fixes cpputest#1790
Fixes cpputest#1741
Fixes cpputest#168
Fixes cpputest#1207

Co-authored-by: Cursor <[email protected]>
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