Wednesday 31 August 2022

React Native Native Java Module Tests run 1 by 1 but won't run under "All Tests"

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, whenever we run "All Tests" in Android Studio we get a false fail

Clicking at Project level and selecting "All Tasks"

enter image description here

gives us

enter image description here

No instrumentation registered! Must run under a registering instrumentation.

But

enter image description here

gives us

enter image description here

can anyone shed light onto why this is happening?

As an aside, after trying to fix this via command line, (i.e. in an effort to diagnose it and bypass it perhaps) I have found that when we run these unit tests under ./gradlew test or adb shell am instrument -w -m -e package net.my.package -e debug false net.my.package.test/androidx.test.runner.AndroidJUnitRunner command line test versions, well ./gradlew test always passes, and the adb shell cmd ALWAYS shows a repeat of the last Visual Studio pass/fail regardless of their actual current test condition (i.e .forced to be fail or otherwise). It's only in the Android Studio UI "right click" they pass or fail legitimately. Command line the pass regardless of their suitability.

the Build Gradle is

dependencies {
    implementation fileTree(dir: "libs", include: ["*.jar"])
    //noinspection GradleDynamicVersion
    implementation "com.facebook.react:react-native:+"  // From node_modules
    implementation project(':react-native-exception-handler')
    implementation project(':react-native-gesture-handler')
    implementation project(':react-native-device-info')
    implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
    implementation project(':react-native-safe-area-context')
    implementation project(':react-native-vector-icons')
    implementation project(':react-native-svg')
    implementation'com.facebook.soloader:soloader:0.9.0+'
    implementation 'com.facebook.fresco:animated-gif:2.6.0'
    testImplementation 'androidx.test:core:1.4.0'
   
    androidTestImplementation('com.wix:detox:+') { transitive = true }
    androidTestImplementation 'junit:junit:4.12'


from React Native Native Java Module Tests run 1 by 1 but won't run under "All Tests"

No comments:

Post a Comment