Skip to content

Split the long UI tests into focused tests, and fix the memory leaks this exposed - #231

Merged
mfl28 merged 8 commits into
masterfrom
test/split-long-ui-tests
Oct 11, 2026
Merged

mfl28 merged 8 commits into
masterfrom
test/split-long-ui-tests

Conversation

@mfl28

@mfl28 mfl28 commented Oct 11, 2026

Copy link
Copy Markdown
Owner

Splits the 7 long UI test scenarios that SonarCloud flagged (S5961, 26–107 assertions each) into focused tests, and fixes the two memory leaks and the menu helper problems that this exposed.

Split tests (one commit per class)

Class Before After
ObjectTreeTests 1 scenario, 107 assertions 7 tests, at most 23 each
BoundingPolygonDrawingTests 2 scenarios, 87 and 32 assertions 9 tests, at most 20 each
BoundingBoxDrawingTests 1 scenario, 57 assertions 6 tests, at most 16 each
SettingsTests (inference) 1 scenario, 64 assertions 5 tests, at most 13 each
SceneKeyShortcutTests 1 scenario 6 tests
ImageFileFilterTests 1 scenario, 26 assertions 3 tests, at most 13 each

Each test builds only the state it needs through shared helpers (e.g. drawing two boxes, building a nested tree, opening the inference settings). The steps and checks are the ones from the old scenarios.

Memory leaks (the full suite hung locally)

  • Cause:
  • Fix:
    • The Controller removes its handlers from the window once the window is hidden.
    • AutosaveController.stop() ends the autosave thread. Deletions still work afterwards; saves are ignored.
    • The app was never affected, because it has one Controller per window.
  • Result: after the fix, 1 Controller is left. The full suite (336 tests) passes in about 6 minutes with no full GCs.

Menu path helper (#227)

  • From the menu bar, the pointer now goes straight down into the menu. The diagonal move crossed the next menu-bar button, which switches menus while one is open; a screenshot showed the Edit menu open.
  • It goes into a submenu straight across at the parent item's height. The robot's reported pointer position was wrong.
  • It looks up the item again after entering a submenu, which can rebuild it.
  • The menu-heavy test classes passed 5 out of 5 runs.

Also: the object tree's preview pop-over no longer opens after its window was closed. Its timer could still fire, which TestFX reported as a failure in the next test.

mfl28 added 8 commits October 11, 2026 13:56
The 107-assertion scenario becomes seven tests (drawing, hiding and
showing, nesting, rebuilding after an image change, deleting, changing the
category, tags) that build only the state they need through shared helpers.

Fix: the object tree's preview pop-over no longer opens after its window
was closed (its timer could still fire, e.g. between UI tests).
The 87-assertion polygon scenario becomes seven tests (drawing, finishing,
switching images, editing vertices, deleting, changing the drawing mode,
adding and deleting vertices), and the freehand test two (while drawing,
after finishing).
The 57-assertion scenario becomes six tests: drawing, switching images,
moving, opening another folder (error report and reset), resizing, and
exiting with unsaved annotations.
The 64-assertion scenario becomes five tests: opening the inference
settings, the controls shown when inference is enabled, their default
values, cancelling changes, and applying invalid settings.
The scenario becomes six tests: the registered shortcuts, navigation,
drawing modes, the settings and focus shortcuts, and the shape shortcuts
with one and with several polygons.
The scenario becomes three tests: filtering by annotation status (with
navigation), filtering by categories until the filter is cleared, and
searching file names.
UI tests show each new Controller in the same TestFX window. Every
Controller left its event filters and handlers on that window and its
autosave thread running, so all earlier apps (with their images) stayed in
memory. With the split UI tests the test JVM ran out of heap and JavaFX
stopped processing events, which hung the full test suite.

The Controller now removes its handlers from the window once it is hidden,
and stopping the autosave ends its thread (deletions still work
afterwards). The app itself has one Controller per window, so it wasn't
affected.
From the menu bar the pointer now goes straight down into the menu (a
diagonal move crossed the next menu-bar button, which switches menus while
one is open), into a submenu straight across at the parent item's height
(the robot's reported pointer position was wrong), and the item is looked
up again after entering a submenu, which can rebuild it.
@sonarqubecloud

Copy link
Copy Markdown

@codecov

codecov Bot commented Oct 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.32%. Comparing base (e9686b5) to head (61904f3).

Files with missing lines Patch % Lines
...mfl28/boundingboxeditor/controller/Controller.java 91.66% 1 Missing and 1 partial ⚠️
...8/boundingboxeditor/ui/WorkspaceSplitPaneView.java 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master     #231      +/-   ##
============================================
+ Coverage     90.24%   90.32%   +0.07%     
- Complexity     2384     2393       +9     
============================================
  Files           140      140              
  Lines          8964     8988      +24     
  Branches        860      863       +3     
============================================
+ Hits           8090     8118      +28     
+ Misses          455      451       -4     
  Partials        419      419              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mfl28
mfl28 merged commit 6e25751 into master Oct 11, 2026
19 checks passed
@mfl28
mfl28 deleted the test/split-long-ui-tests branch October 11, 2026 13:38
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