Skip to content

test: [SDK-5538] guard stand-ins and the public API against drift - #2828

Draft
abdulraqeeb33 wants to merge 1 commit into
never-crash/4-never-crash-initfrom
never-crash/5-api-coverage-tests
Draft

abdulraqeeb33 wants to merge 1 commit into
never-crash/4-never-crash-initfrom
never-crash/5-api-coverage-tests

Conversation

@abdulraqeeb33

@abdulraqeeb33 abdulraqeeb33 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Stack (base feat/never-crash, merged to main as one unit; split out of #2793):

  1. refactor: [SDK-5538] add SdkOperation names for init-gated entry points #2800 SdkOperation names
  2. feat: [SDK-5538] remote kill switch with a placeholder OneSignalImpV2 #2801 Kill switch with a placeholder OneSignalImpV2
  3. feat: [SDK-5538] deferred managers that stand in before init #2802 Deferred managers
  4. fix: [SDK-5538] never crash on invalid init or calls before init #2803 Never-crash init
  5. test: [SDK-5538] guard stand-ins and the public API against drift #2828 Drift tests for the stand-ins and the public API (this PR)

Description

One Line Summary

Tests that fail when a new public method is added without deciding how it behaves before init.

Details

Motivation

Part of SDK-5538. The compiler already forces every new abstract interface method into its stand-in, but not a method with a default body, not whether a new listener is queued before init, and not whether a new IOneSignal method checks the init gate. These tests cover those gaps.

Scope

Test-only, two files (215 lines):

  • DeferredManagersCoverageTests
    • Every member of the six manager interfaces is declared on its stand-in, not inherited from a default body. The failure names the member and the stand-in.
    • Every add...Listener, add...Observer and settable property must be listed in the replay table. A new one fails until someone decides whether it queues before init.
    • Each listed call is queued before init and reaches the real manager exactly once on replay.
  • OneSignalImpV2ApiSweepTests
    • Every IOneSignal member, called before init with dummy arguments, must not throw or hang past 5 seconds.
    • The same sweep runs over every member of the managers handed out before init (User, pushSubscription, Notifications, InAppMessages, Location, Session).

Not covered

  • Members that need a non-null Context are skipped, since they would start a real init. The nullable-context variants are swept.
  • The JWT invalidated listener isn't a manager interface, so only "doesn't throw" is checked for it.
  • IDebugManager is a real object before init; only the debug getter is called.
  • A call that blocks its thread forever would hang the run instead of failing with the message.

Testing

Unit testing

Each test was checked against a deliberate breakage, and all went red naming it: a new default-body method on ISessionManager, a new default-body listener on IInAppMessagesManager, isShared no longer queued, a stand-in method that throws, logout() throwing before init, and a suspend getter that hangs. core, location, in-app-messages, notifications, spotless, detekt and apiCheck pass.

Manual testing

Not needed, test-only.

Affected code checklist

  • Notifications
    • Display
    • Open
    • Push Processing
    • Confirm Deliveries
  • Outcomes
  • Sessions
  • In-App Messaging
  • REST API requests
  • Public API changes

Checklist

Overview

  • I have filled out all REQUIRED sections above
  • PR does one thing
  • Any Public API changes are explained in the PR details and conform to existing APIs

Testing

  • I have included test coverage for these changes, or explained why they are not needed
  • All automated tests pass, or I explained why that is not possible
  • I have personally tested this on my device, or explained why that is not possible

Final pass

  • Code is as readable as possible.
  • I have reviewed this PR myself, ensuring it meets each checklist item

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

📊 Diff Coverage Report

Diff Coverage Report (Changed Lines Only)

Gate: aggregate coverage on changed executable lines must be ≥ 80% (JaCoCo line data for lines touched in the diff).

Changed Files Coverage

✅ No main-source changes to gate

No Kotlin/Java changes in the diff.

📥 View workflow run

DeferredManagersCoverageTests: every member of the six manager interfaces
must be declared on its stand-in, not inherited from a default body. Every
add...Listener/Observer and every var must have a replay case, and each case
must queue before init and reach the real manager on replay.

OneSignalImpV2ApiSweepTests: every IOneSignal member, and every member of the
managers handed out before init, is called reflectively with dummy args and
must not throw or hang past 5s. Members that need a non-null Context are
skipped, since they would start a real init.

Co-authored-by: Cursor <cursoragent@cursor.com>
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