Skip to content

Add real-touch UI tests for the SwiftUI example - #43

Merged
daisuke0131 merged 1 commit into
masterfrom
feat/ui-tests
Aug 9, 2026
Merged

Add real-touch UI tests for the SwiftUI example#43
daisuke0131 merged 1 commit into
masterfrom
feat/ui-tests

Conversation

@daisuke0131

Copy link
Copy Markdown
Owner

Summary

  • Add an XCUITest bundle (ViewMonitorSwiftUIExampleUITests) to the SwiftUI example, generated by generate_project.rb like the rest of the project, and run it on CI in the example job
  • Expose accessibility identifiers on ViewMonitor's own UI (ViewMonitor.launcher / ViewMonitor.monitorButton / ViewMonitor.infoView) so tests can address it; covered by unit tests

Why

Unit tests reproduce taps with sendActions and one-shot hitTest, which can diverge from the real touch pipeline. The launcher-toggle teardown bug and the shield hit-test bug (2.3.0) both shipped past the unit suite and were only caught manually on device. XCUITest drives the app through the system's real touch delivery and attaches as an accessibility client, so SwiftUI element detection is active during tests without the debug-only enabler.

Coverage

  1. Toggle ON → tap a UIKit nav label → measurement rows appear in the InfoView
  2. Tap a SwiftUI Textclass: Text and text: rows appear
  3. Navigate to the List (while OFF), toggle ON → rows get monitor buttons
  4. Shield: tapping a covered NavigationLink selects it for measurement instead of navigating, empty-area taps are absorbed, and the toggle stays ON

Verification

  • 4 UI tests pass locally in ~30s; 125 unit tests / 20 suites green; swiftlint --strict 0 violations (UI test sources added to lint scope)
  • Sabotage check: temporarily reintroducing the old inside-the-target button placement makes test 1 fail, confirming the harness catches the class of bug that previously required a physical device to find

🤖 Generated with Claude Code

Unit tests reproduce taps with sendActions and one-shot hitTest, which
can diverge from the real touch pipeline: the launcher toggle teardown
and the shield hit-test bugs both shipped past the unit suite and were
only caught by hand on device. Add an XCUITest bundle to the SwiftUI
example (generated by generate_project.rb like the rest of the project)
covering the flows those bugs broke:

- toggle ON, tap a UIKit nav label, measurement appears in the InfoView
- tap a SwiftUI Text, measurement (class/text) appears
- List rows get monitor buttons after navigating and toggling ON
- the shield keeps taps from reaching the app: a covered NavigationLink
  selects for measurement instead of navigating, empty-area taps are
  absorbed, and the toggle stays ON

XCUITest attaches as an accessibility client, so SwiftUI element
detection is active during the tests without the debug-only enabler.
Reintroducing the old inside-the-target button placement makes the nav
label test fail, confirming the harness catches that class of bug on
the simulator's real-touch path.

ViewMonitor's launcher, monitor buttons, and InfoView now expose
accessibility identifiers (ViewMonitor.launcher / .monitorButton /
.infoView) so tests can address them; covered by unit tests.

CI runs the bundle in the example job via xcodebuild test.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@daisuke0131
daisuke0131 merged commit e40b33b into master Aug 9, 2026
4 checks passed
@daisuke0131
daisuke0131 deleted the feat/ui-tests branch August 9, 2026 06:39
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