Android 仪器测试并未在某些设备上全部运行

问题描述 投票:0回答:1

我有一个 Android 应用程序,包含 225 次浓缩咖啡测试。 到目前为止,我始终能够在所有设备上以原始方式运行所有测试(三星智能手机和平板电脑,从 Android 7 到 14) 我现在拥有一部全新的三星 A15。 在此设备上,测试永远不会结束 225 次测试。所有运行测试都顺利通过,但它们随机停止,最常见的是 70 到 120 之间。

大约在失败时,logcat 显示以下内容:

2024-08-26 07:11:07.999  6224-6244  ShellCommandClient      androidx.test.orchestrator           E  Couldn't find a published binder
2024-08-26 07:11:08.015  6224-6244  ShellExecutorImpl       androidx.test.orchestrator           E  ShellCommandClient not connected. Is ShellCommandExecutor service started?
                                                                                                    androidx.test.services.shellexecutor.ClientNotConnected: Couldn't find a binder published by androidx.test.services. It is very likely that androidx.test.services was killed, which is usually due to low memory conditions. Consider switching to a device with more memory.

在 IDE 中,我得到这个:

> Task :app:connectedDevelopmentDebugAndroidTest
Test run failed to complete. Instrumentation run failed due to Process crashed.
> Task :app:connectedDevelopmentDebugAndroidTest FAILED
FAILURE: 
Build failed with an exception.
* What went wrong:
Execution failed for task ':app:connectedDevelopmentDebugAndroidTest'.

这不是设备内存大小(A15)的问题,因为它可以在具有相同内存大小和操作系统(4GB,Android 14)的 A13 上完美运行,并且在具有 1.5 GB 内存的 A3 上也可以完美运行。 我还重新启动了设备,重建了所有内容,清理了 IDE 的缓存,从设备中删除了 2 个应用程序:androidx.test.orchestrator 和 TestServices。 这没有帮助。

我将所有开发者设置与A13的进行了比较:它们是相同的。

知道发生了什么以及如何解决这个问题吗?

android android-espresso instrumented-test
1个回答
0
投票

考虑将它们分成较小的批次,并在单独的检测进程中运行它们。 build.gradle 中的 testInstrumentationRunnerArguments

android {
    defaultConfig {
        testInstrumentationRunnerArguments clearPackageData: 'true'
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.