You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If pbandk's JSON functionality (e.g. Message.encodeToJsonString()) is used from within an Android unit test, the unit test fails to run because the JVM used for running unit tests does not have an android.util.Base64 implementation. android.* dependencies are only available to tests in the androidTest source set, which run on real or emulated devices rather than on the local JVM.
Robolectric provides a robust way to run unit tests that include Android dependencies on the JVM by simulating many Android APIs without running an actual device; but it requires using the Robolectric test runner and modifying tests to initialize the simulated environment appropriately. However, there is a lighter-weight way of using Robolectric if UI-related Android APIs aren't needed (Context, Activity, etc.). In that case, all that's needed is a dependency on the platform-specific Robolectric runtime library:
If pbandk's JSON functionality (e.g.
Message.encodeToJsonString()
) is used from within an Android unit test, the unit test fails to run because the JVM used for running unit tests does not have anandroid.util.Base64
implementation.android.*
dependencies are only available to tests in theandroidTest
source set, which run on real or emulated devices rather than on the local JVM.Robolectric provides a robust way to run unit tests that include Android dependencies on the JVM by simulating many Android APIs without running an actual device; but it requires using the Robolectric test runner and modifying tests to initialize the simulated environment appropriately. However, there is a lighter-weight way of using Robolectric if UI-related Android APIs aren't needed (
Context
,Activity
, etc.). In that case, all that's needed is a dependency on the platform-specific Robolectric runtime library:If the above dependency is added to the Android project that uses pbandk, then pbandk's JSON-related methods will run successfully from unit tests.
The text was updated successfully, but these errors were encountered: