Skip to content

unit tests updated#8274

Merged
markdevocht merged 4 commits intomasterfrom
bugfix/(RN77-NA)-Android-Enable-Native-Unit-Tests-#8011
Apr 15, 2026
Merged

unit tests updated#8274
markdevocht merged 4 commits intomasterfrom
bugfix/(RN77-NA)-Android-Enable-Native-Unit-Tests-#8011

Conversation

@markdevocht
Copy link
Copy Markdown
Contributor

Re-enable Android Robolectric unit tests disabled since New Architecture migration

When RNN migrated to React Native's New Architecture (Fabric), 27 Android unit test classes were disabled with @Ignore because ReactView now loads native libraries (rninstance via SoLoader) during construction — which fails under Robolectric since there's no real Android runtime.

The fix introduces two Robolectric shadow classes to intercept the native initialization chain without modifying any production code:

  • ShadowSoLoader — stubs SoLoader.loadLibrary calls as no-ops, preventing native .so loading attempts.
  • ShadowReactView — shadows ReactView's constructor to invoke FrameLayout's constructor directly, bypassing ReactHost.createSurface() and the entire native rendering pipeline. Also shadows lifecycle methods (onAttachedToWindow, start, destroy) to prevent NPEs from the missing reactSurface.

Supporting changes:

  • TestApplication.reactHost returns a Mockito mock instead of calling getDefaultReactHost(), which would trigger native initialization.
  • SimpleViewController.SimpleView extends FrameLayout directly instead of ReactView, implementing ReactComponent interface explicitly.
  • Fixed a MockedStatic double-close bug in BaseTest.beforeEach.

Result: All 687 unit tests now pass (2 pre-existing method-level @Ignores remain).

@markdevocht markdevocht linked an issue Apr 15, 2026 that may be closed by this pull request
3 tasks
@markdevocht markdevocht merged commit 3c42afb into master Apr 15, 2026
3 checks passed
@markdevocht markdevocht deleted the bugfix/(RN77-NA)-Android-Enable-Native-Unit-Tests-#8011 branch April 15, 2026 11:44
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.

(RN77-NA) Android: Enable Native Unit Tests

1 participant