React Native Native Java Module Tests run when 'androidTest' but not when 'Test'

Viewed 113

I am on a MacBook Running Android Studio

Under a React Native Project, the TypeScript tests run fine with jest but when we added JUnit tests under a Native Java Module, while it works individually or by folder as long as they are in androidTest, whenever we run "All Tests" in Android Studio, or when they are run under test we get a false fail. The error is always the same.

Running the same tests under Android Tests works

when in android/app/src/androidTest/.../

enter image description here

gives

enter image description here

Yet running the same tests under Tests fails

when I copy them into android/app/src/test/.../

enter image description here

or leave them in androidTest and run all tests

enter image description here

it always gives

enter image description here

So, all these unit tests live happily in android/app/src/androidTest/.../ and do not like being in android/app/src/test/.../ (when I copy/paste them to the android/app/src/test/.../ path the androidTest passes in the ide, but the test version of the same test doesn't pass) But the bad part is the fail is the same: They fail under "Run 'All Tests'" when in /androidTest and give the same reason as if they are wrongly in /test. i.e. "Run 'All Tests'" and "Run unit tests in ''" both fail for the same reason

this is the error dump I get

Executing tasks: [:app:testDebugUnitTest] in project 

/Users/local/some/domain/my-app/android


> Configure project :
Repository BintrayJCenter (https://jcenter.bintray.com/) removed, using https://pkgs.dev.azure.com/somedomain/O-Common/maven/v1
Repository MavenRepo (https://repo.maven.apache.org/maven2/) removed, using https://pkgs.dev.azure.com/somedomain/O-Common/maven/v1
Repository Google (https://dl.google.com/dl/android/maven2/) removed, using https://pkgs.dev.azure.com/somedomain/O-Common/maven/v1
...

> Task :app:generatePackageList
> Task :app:preBuild
> Task :app:preDebugBuild
> Task :react-native-community_art:preBuild UP-TO-DATE
> Task :react-native-community_art:preDebugBuild UP-TO-DATE
> Task :react-native-community_art:compileDebugAidl NO-SOURCE
> Task :react-native-community_masked-view:preBuild UP-TO-DATE
> Task :react-native-community_masked-view:preDebugBuild UP-TO-DATE
> Task :react-native-community_masked-view:compileDebugAidl NO-SOURCE
> Task :react-native-cookies:preBuild UP-TO-DATE
> Task :react-native-cookies:preDebugBuild UP-TO-DATE
> Task :react-native-cookies:compileDebugAidl NO-SOURCE
> Task :react-native-datawedge-intents:preBuild UP-TO-DATE
> Task :react-native-datawedge-intents:preDebugBuild UP-TO-DATE
> Task :react-native-datawedge-intents:compileDebugAidl NO-SOURCE
> Task :react-native-device-info:preBuild UP-TO-DATE
> Task :react-native-device-info:preDebugBuild UP-TO-DATE
> Task :react-native-device-info:compileDebugAidl NO-SOURCE
> Task :react-native-exception-handler:preBuild UP-TO-DATE
> Task :react-native-exception-handler:preDebugBuild UP-TO-DATE
> Task :react-native-exception-handler:compileDebugAidl NO-SOURCE
> Task :react-native-gesture-handler:preBuild UP-TO-DATE
> Task :react-native-gesture-handler:preDebugBuild UP-TO-DATE
> Task :react-native-gesture-handler:compileDebugAidl NO-SOURCE
> Task :react-native-safe-area-context:preBuild UP-TO-DATE
> Task :react-native-safe-area-context:preDebugBuild UP-TO-DATE
> Task :react-native-safe-area-context:compileDebugAidl NO-SOURCE
> Task :react-native-screens:preBuild UP-TO-DATE
> Task :react-native-screens:preDebugBuild UP-TO-DATE
> Task :react-native-screens:compileDebugAidl NO-SOURCE
> Task :react-native-sound:preBuild UP-TO-DATE
> Task :react-native-sound:preDebugBuild UP-TO-DATE
> Task :react-native-sound:compileDebugAidl NO-SOURCE
> Task :react-native-svg:preBuild UP-TO-DATE
> Task :react-native-svg:preDebugBuild UP-TO-DATE
> Task :react-native-svg:compileDebugAidl NO-SOURCE
> Task :react-native-vector-icons:preBuild UP-TO-DATE
> Task :react-native-vector-icons:preDebugBuild UP-TO-DATE
> Task :react-native-vector-icons:compileDebugAidl NO-SOURCE
> Task :react-native-version-number:preBuild UP-TO-DATE
> Task :react-native-version-number:preDebugBuild UP-TO-DATE
> Task :react-native-version-number:compileDebugAidl NO-SOURCE
> Task :app:compileDebugAidl NO-SOURCE
> Task :react-native-community_art:packageDebugRenderscript NO-SOURCE
> Task :react-native-community_masked-view:packageDebugRenderscript NO-SOURCE
> Task :react-native-cookies:packageDebugRenderscript NO-SOURCE
> Task :react-native-datawedge-intents:packageDebugRenderscript NO-SOURCE
> Task :react-native-device-info:packageDebugRenderscript NO-SOURCE
> Task :react-native-exception-handler:packageDebugRenderscript NO-SOURCE
> Task :react-native-gesture-handler:packageDebugRenderscript NO-SOURCE
> Task :react-native-safe-area-context:packageDebugRenderscript NO-SOURCE
> Task :react-native-screens:packageDebugRenderscript NO-SOURCE
> Task :react-native-sound:packageDebugRenderscript NO-SOURCE
> Task :react-native-svg:packageDebugRenderscript NO-SOURCE
> Task :react-native-vector-icons:packageDebugRenderscript NO-SOURCE
> Task :react-native-version-number:packageDebugRenderscript NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:generateDebugBuildConfig UP-TO-DATE
> Task :app:javaPreCompileDebug UP-TO-DATE
> Task :react-native-community_art:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-community_masked-view:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-cookies:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-datawedge-intents:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-device-info:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-exception-handler:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-gesture-handler:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-safe-area-context:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-screens:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-sound:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-svg:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-vector-icons:writeDebugAarMetadata UP-TO-DATE
> Task :react-native-version-number:writeDebugAarMetadata UP-TO-DATE
> Task :app:checkDebugAarMetadata UP-TO-DATE
> Task :app:bundleDebugJsAndAssets
Execution optimizations have been disabled for task ':app:bundleDebugJsAndAssets' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/Users/local/some/domain/my-app'. Reason: Task ':app:bundleDebugJsAndAssets' uses this output of task ':react-native-version-number:writeDebugAarMetadata' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
warn Package lint-staged has been ignored because it contains invalid configuration. Reason: Package subpath './package.json' is not defined by "exports" in /Users/local/some/domain/my-app/node_modules/lint-staged/package.json
warning: the transform cache was reset.
                    Welcome to Metro!
              Fast - Scalable - Integrated
info Writing bundle output to:, /Users/local/some/domain/my-app/android/app/build/generated/assets/react/debug/index.android.bundle
info Writing sourcemap output to:, /Users/local/some/domain/my-app/android/app/build/generated/sourcemaps/react/debug/index.android.bundle.map
info Done writing bundle output
info Done writing sourcemap output
info Copying 36 asset files
info Done copying assets
> Task :app:mergeDebugShaders UP-TO-DATE
> Task :app:compileDebugShaders NO-SOURCE
> Task :app:generateDebugAssets UP-TO-DATE
> Task :react-native-community_art:mergeDebugShaders UP-TO-DATE
> Task :react-native-community_art:compileDebugShaders NO-SOURCE
> Task :react-native-community_art:generateDebugAssets UP-TO-DATE
> Task :react-native-community_art:packageDebugAssets UP-TO-DATE
> Task :react-native-community_masked-view:mergeDebugShaders UP-TO-DATE
> Task :react-native-community_masked-view:compileDebugShaders NO-SOURCE
> Task :react-native-community_masked-view:generateDebugAssets UP-TO-DATE
> Task :react-native-community_masked-view:packageDebugAssets UP-TO-DATE
> Task :react-native-cookies:mergeDebugShaders UP-TO-DATE
> Task :react-native-cookies:compileDebugShaders NO-SOURCE
> Task :react-native-cookies:generateDebugAssets UP-TO-DATE
> Task :react-native-cookies:packageDebugAssets UP-TO-DATE
> Task :react-native-datawedge-intents:mergeDebugShaders UP-TO-DATE
> Task :react-native-datawedge-intents:compileDebugShaders NO-SOURCE
> Task :react-native-datawedge-intents:generateDebugAssets UP-TO-DATE
> Task :react-native-datawedge-intents:packageDebugAssets UP-TO-DATE
> Task :react-native-device-info:mergeDebugShaders UP-TO-DATE
> Task :react-native-device-info:compileDebugShaders NO-SOURCE
> Task :react-native-device-info:generateDebugAssets UP-TO-DATE
> Task :react-native-device-info:packageDebugAssets UP-TO-DATE
> Task :react-native-exception-handler:mergeDebugShaders UP-TO-DATE
> Task :react-native-exception-handler:compileDebugShaders NO-SOURCE
> Task :react-native-exception-handler:generateDebugAssets UP-TO-DATE
> Task :react-native-exception-handler:packageDebugAssets UP-TO-DATE
> Task :react-native-gesture-handler:mergeDebugShaders UP-TO-DATE
> Task :react-native-gesture-handler:compileDebugShaders NO-SOURCE
> Task :react-native-gesture-handler:generateDebugAssets UP-TO-DATE
> Task :react-native-gesture-handler:packageDebugAssets UP-TO-DATE
> Task :react-native-safe-area-context:mergeDebugShaders UP-TO-DATE
> Task :react-native-safe-area-context:compileDebugShaders NO-SOURCE
> Task :react-native-safe-area-context:generateDebugAssets UP-TO-DATE
> Task :react-native-safe-area-context:packageDebugAssets UP-TO-DATE
> Task :react-native-screens:mergeDebugShaders UP-TO-DATE
> Task :react-native-screens:compileDebugShaders NO-SOURCE
> Task :react-native-screens:generateDebugAssets UP-TO-DATE
> Task :react-native-screens:packageDebugAssets UP-TO-DATE
> Task :react-native-sound:mergeDebugShaders UP-TO-DATE
> Task :react-native-sound:compileDebugShaders NO-SOURCE
> Task :react-native-sound:generateDebugAssets UP-TO-DATE
> Task :react-native-sound:packageDebugAssets UP-TO-DATE
> Task :react-native-svg:mergeDebugShaders UP-TO-DATE
> Task :react-native-svg:compileDebugShaders NO-SOURCE
> Task :react-native-svg:generateDebugAssets UP-TO-DATE
> Task :react-native-svg:packageDebugAssets UP-TO-DATE
> Task :react-native-vector-icons:mergeDebugShaders UP-TO-DATE
  - Gradle detected a problem with the following location: '/Users/local/some/domain/my-app/android/app/build/intermediates/navigation_json/debug/navigation.json'. Reason: Task ':app:processDebugMainManifest' uses this output of task ':app:copyDebugBundledJs' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/Users/local/some/domain/my-app/android/app/build/intermediates/navigation_json/debug/navigation.json'. Reason: Task ':app:processDebugMainManifest' uses this output of task ':app:copyDebugReactNativeVectorIconFonts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
/Users/local/some/domain/my-app/android/app/src/debug/AndroidManifest.xml:7:5-12:19 Warning:
    application@android:allowBackup was tagged at AndroidManifest.xml:7 to replace other declarations but no other declaration present
> Task :app:processDebugManifest
Execution optimizations have been disabled for task ':app:processDebugManifest' to ensure correctness due to the following reasons:
  - Gradle detected a problem with the following location: '/Users/local/some/domain/my-app/android/app/build/intermediates/compatible_screen_manifest/debug'. Reason: Task ':app:processDebugManifest' uses this output of task ':app:copyDebugBundledJs' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/Users/local/some/domain/my-app/android/app/build/intermediates/compatible_screen_manifest/debug'. Reason: Task ':app:processDebugManifest' uses this output of task ':app:copyDebugReactNativeVectorIconFonts' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/Users/local/some/domain/my-app/android/app/build/intermediates/merged_manifest/debug/AndroidManifest.xml'. Reason: Task ':app:processDebugManifest' uses this output of task ':app:copyDebugBundledJs' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed. Please refer to https://docs.gradle.org/7.2/userguide/validation_problems.html#implicit_dependency for more details about this problem.
> Task :react-native-svg:processDebugJavaRes NO-SOURCE
> Task :react-native-svg:bundleLibResDebug NO-SOURCE
> Task :react-native-svg:bundleLibRuntimeToJarDebug UP-TO-DATE
> Task :react-native-vector-icons:processDebugJavaRes NO-SOURCE
> Task :react-native-vector-icons:bundleLibResDebug NO-SOURCE
> Task :react-native-vector-icons:bundleLibRuntimeToJarDebug UP-TO-DATE
> Task :react-native-version-number:processDebugJavaRes NO-SOURCE
> Task :react-native-version-number:bundleLibResDebug NO-SOURCE
> Task :react-native-version-number:bundleLibRuntimeToJarDebug UP-TO-DATE
> Task :app:processDebugResources
> Task :app:compileDebugJavaWithJavac UP-TO-DATE
> Task :app:bundleDebugClasses UP-TO-DATE
> Task :app:compileDebugUnitTestJavaWithJavac UP-TO-DATE
> Task :app:packageDebugUnitTestForUnitTest UP-TO-DATE
> Task :app:generateDebugUnitTestConfig UP-TO-DATE
> Task :app:testDebugUnitTest
Called loadFromPath(/system/framework/framework-res.apk, true); mode=binary sdk=28

java.lang.NullPointerException
    at java.base/java.io.File.<init>(File.java:278)
    at com.facebook.soloader.ApplicationSoSource.<init>(ApplicationSoSource.java:46)
    at com.facebook.soloader.SoLoader.initSoSources(SoLoader.java:285)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:207)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:189)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:217)
    at uk.some.domain.myapp.MainApplication.onCreate(MainApplication.java:78)
    at org.robolectric.android.internal.AndroidTestEnvironment.lambda$installAndCreateApplication$0(AndroidTestEnvironment.java:288)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:75)
    at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:288)
    at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:171)
    at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:254)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)


java.lang.NullPointerException
    at java.base/java.io.File.<init>(File.java:278)
    at com.facebook.soloader.ApplicationSoSource.<init>(ApplicationSoSource.java:46)
    at com.facebook.soloader.SoLoader.initSoSources(SoLoader.java:285)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:207)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:189)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:217)
    at uk.some.domain.myapp.MainApplication.onCreate(MainApplication.java:78)
    at org.robolectric.android.internal.AndroidTestEnvironment.lambda$installAndCreateApplication$0(AndroidTestEnvironment.java:288)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:75)
    at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:288)
    at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:171)
    at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:254)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)


java.lang.NullPointerException
    at java.base/java.io.File.<init>(File.java:278)
    at com.facebook.soloader.ApplicationSoSource.<init>(ApplicationSoSource.java:46)
    at com.facebook.soloader.SoLoader.initSoSources(SoLoader.java:285)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:207)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:189)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:217)
    at uk.some.domain.myapp.MainApplication.onCreate(MainApplication.java:78)
    at org.robolectric.android.internal.AndroidTestEnvironment.lambda$installAndCreateApplication$0(AndroidTestEnvironment.java:288)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:75)
    at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:288)
    at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:171)
    at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:254)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)


java.lang.NullPointerException
    at java.base/java.io.File.<init>(File.java:278)
    at com.facebook.soloader.ApplicationSoSource.<init>(ApplicationSoSource.java:46)
    at com.facebook.soloader.SoLoader.initSoSources(SoLoader.java:285)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:207)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:189)
    at com.facebook.soloader.SoLoader.init(SoLoader.java:217)
    at uk.some.domain.myapp.MainApplication.onCreate(MainApplication.java:78)
    at org.robolectric.android.internal.AndroidTestEnvironment.lambda$installAndCreateApplication$0(AndroidTestEnvironment.java:288)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:75)
    at org.robolectric.android.internal.AndroidTestEnvironment.installAndCreateApplication(AndroidTestEnvironment.java:288)
    at org.robolectric.android.internal.AndroidTestEnvironment.setUpApplicationState(AndroidTestEnvironment.java:171)
    at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:319)
    at org.robolectric.internal.SandboxTestRunner$2.lambda$evaluate$0(SandboxTestRunner.java:254)
    at org.robolectric.internal.bytecode.Sandbox.lambda$runOnMainThread$0(Sandbox.java:89)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at java.base/java.lang.Thread.run(Thread.java:829)


uk.some.domain.myapp.HubTest > testSendEvent_Object FAILED
    java.lang.NullPointerException at File.java:278
uk.some.domain.myapp.HubTest > testSendEvent_String FAILED
    java.lang.NullPointerException at File.java:278
uk.some.domain.myapp.HubTest > testBridgeHelloWorld FAILED
    java.lang.NullPointerException at File.java:278
uk.some.domain.myapp.HubTest > testResetScreenTimer FAILED
    java.lang.NullPointerException at File.java:278
4 tests completed, 4 failed
> Task :app:testDebugUnitTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:testDebugUnitTest'.
> There were failing tests. See the report at: file:///Users/local/some/domain/my-app/android/app/build/reports/tests/testDebugUnitTest/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
See https://docs.gradle.org/7.2/userguide/command_line_interface.html#sec:command_line_warnings
Execution optimizations have been disabled for 4 invalid unit(s) of work during this build to ensure correctness.
Please consult deprecation warnings for more details.
BUILD FAILED in 44s
220 actionable tasks: 7 executed, 213 up-to-date
13:20:03: Task execution finished ':app:testDebugUnitTest --tests "uk.some.domain.myapp.*"'.

For CI reasons it needs to run under "All Tasks" it appears to be emulator related, can anyone shed light on the cause?

1 Answers

I think this is related to Unit VS Instrumentation tests.

Unit is made for single method / small part of code testing on the local machine (Test folder). Instrumentation tests on the other hand are made for a more complex testing of features, directly on an emulator (AndroidTest folder).

Possible Solution :

First, I would check every test and ensure they have to run on machine or in emulator, and set them in the proper directory.

Then, you 'll have to run an emulator in your CI to make all your instrumentation tests run properly.

Check testing fundamentals for more informations

Related