Improve stability of Android ReactNative E2E test (#21969)

- Remove redundant `OnnxruntimeModuleExampleE2ETest CheckOutputComponentExists` test
- Attempt to close any Application Not Responding (ANR) dialog prior to running Android test
- Add `--take-screenshots failing` option to detox test commands to save screenshots on failure
This commit is contained in:
Edward Chen 2024-09-04 08:41:07 -07:00 committed by GitHub
parent d4290f6e7f
commit cbf3c50d75
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 15 additions and 11 deletions

View file

@ -4,6 +4,8 @@
package com.example.reactnativeonnxruntimemodule;
import android.content.Intent;
import com.wix.detox.Detox;
import com.wix.detox.config.DetoxConfig;
@ -11,6 +13,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import androidx.test.core.app.ApplicationProvider;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.LargeTest;
import androidx.test.rule.ActivityTestRule;
@ -23,6 +26,9 @@ public class DetoxTest {
@Test
public void runDetoxTests() {
// try to close any existing ANR dialog which will interfere with the UI tests
ApplicationProvider.getApplicationContext().sendBroadcast(new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS));
DetoxConfig detoxConfig = new DetoxConfig();
detoxConfig.idlePolicyConfig.masterTimeoutSec = 90;
detoxConfig.idlePolicyConfig.idleResourceTimeoutSec = 60;
@ -30,4 +36,4 @@ public class DetoxTest {
Detox.runTests(mActivityRule, detoxConfig);
}
}
}

View file

@ -8,14 +8,6 @@ describe('OnnxruntimeModuleExample', () => {
await device.launchApp();
});
beforeEach(async () => {
await device.launchApp({ newInstance: true });
});
it('OnnxruntimeModuleExampleE2ETest CheckOutputComponentExists', async () => {
await element(by.label('output'));
});
it('OnnxruntimeModuleExampleE2ETest CheckInferenceResultValueIsCorrect', async () => {
if (device.getPlatform() === 'ios') {
await expect(element(by.label('output')).atIndex(1)).toHaveText('Result: 3');

View file

@ -267,7 +267,10 @@ stages:
- script: |
JEST_JUNIT_OUTPUT_FILE=$(Build.SourcesDirectory)/js/react_native/e2e/android-test-results.xml \
detox test --record-logs all --configuration android.emu.release --loglevel trace
detox test --record-logs all \
--configuration android.emu.release \
--loglevel trace \
--take-screenshots failing
workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e'
displayName: Run React Native Detox Android e2e Tests
@ -318,7 +321,10 @@ stages:
- script: |
JEST_JUNIT_OUTPUT_FILE=$(Build.SourcesDirectory)/js/react_native/e2e/ios-test-results.xml \
detox test --record-logs all --configuration ios.sim.release --loglevel trace
detox test --record-logs all \
--configuration ios.sim.release \
--loglevel trace \
--take-screenshots failing
workingDirectory: '$(Build.SourcesDirectory)/js/react_native/e2e'
displayName: Run React Native Detox iOS e2e Tests