Android Instrumentation 测试已取消,但在设备上运行

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

在我能够成功运行仪器测试的项目中,将 Android Studio 升级到 Giraffe 后,现在仪器测试无法连接到测试设备,并且测试在启动时被取消。

当我运行任何测试时,它会发出警告,表示测试已取消,之前 adb 命令会导致“已连接”状态,现在它也不会出现。

最后,测试在我的设备中运行,尽管 Android Studio 将其显示为已取消。另外,如果我运行; adb shell am Instrument -w -m --no-window-animation -e debug false -e class 'com..sample.tests.PoiInteractionTests#test_rich_poi_213' com..demo.mock.prod.test/android.support .test.runner.AndroidJUnitRunner

在终端上运行命令,我看到我的测试在终端中成功运行。

我尝试将gradle插件升级到7.4.2。我尝试使缓存无效并重新启动 Android Studio。他们都没有工作。最终结果是这样的;

android android-studio instrumentation
1个回答
0
投票

首先将 Android Studio 配置为

Run Android Instrumention Tests using Gradle.
,就像此处建议的那样。 https://stackoverflow.com/a/77271279/10517151

然后将您的 Gradle 和 Android Gradle 插件版本最好升级到最新的稳定版本。

© www.soinside.com 2019 - 2024. All rights reserved.