Den*_*nis 12 junit android android-espresso
我的 Pixel 4a 已升级到 Android 12,现在,当我尝试在该设备上运行 Espresso 测试时,没有运行任何测试。Android Studio 显示“测试通过 0 通过”。没有进行任何测试。测试仍然在 Android 11 设备上按预期运行。
我的测试方法用 org.junit.Test 注释。我的测试类用 androidx.test.filters.LargeTest 注释。
我确保升级 Android Studio。我在 build.gradle 中将compileSdkVersion和targetSdkVersion更新为31。我检查了我的测试依赖项并将其更新为以下版本:
junit:junit:4.13.2
androidx.test.ext:junit-ktx:1.1.3
androidx.test:runner:1.4.0
androidx.test:rules:1.4.0
androidx.test.uiautomator:uiautomator:2.2.0
androidx.test.espresso:espresso-core:3.4.0
androidx.work:work-testing:2.7.0
Run Code Online (Sandbox Code Playgroud)
经过所有这些更改,问题仍然存在,我也在 AVD 上看到过它。
还有其他人遇到过这个问题吗?
小智 12
如果您想使用测试编排器
确保您拥有最新的协调器和测试运行器版本。
androidTestUtil 'androidx.test:orchestrator:1.4.1'
androidTestImplementation 'androidx.test:runner:1.4.0'
Run Code Online (Sandbox Code Playgroud)
确保这是在您testOptions的app/build.gradle.
execution 'ANDROIDX_TEST_ORCHESTRATOR'
Run Code Online (Sandbox Code Playgroud)
或者,如果您不想使用测试协调器
从 app/build.gradle 的 testOptions 中删除以下行。
execution 'ANDROIDX_TEST_ORCHESTRATOR'
Run Code Online (Sandbox Code Playgroud)
在 androidTest 文件夹中创建 AndroidManifest.xml,并添加以下查询权限,通过允许 Orchestrator 包与测试包通信来解决“未找到测试”的问题
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="your.package.name">
<!-- This Manifest will only apply changes to androidTest builds -->
<queries>
<package android:name="androidx.test.orchestrator.OrchestratorService"/>
</queries>
<application android:forceQueryable="true" />
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3161 次 |
| 最近记录: |