android - 为 Facebook screenshot-tests-for-android 设置 gradle 插件的问题

标签 android android-testing

我需要为 android 实现屏幕截图测试。

我已按照 https://facebook.github.io/screenshot-tests-for-android/#gradle-setup 上的步骤操作并在我的 gradle 文件中包含以下内容

buildscript {
    // ...
    dependencies {
      // ...
      classpath 'com.facebook.testing.screenshot:plugin:0.9.0'
    }
  }

  apply plugin: 'com.facebook.testing.screenshot'

但是,我得到一个错误

A problem occurred evaluating root project 'app-android'. Failed to apply plugin [id 'com.facebook.testing.screenshot'] Configuration with name 'androidTestImplementation' not found.

我的 build.gradle 中有以下内容

androidTestImplementation 'androidx.test:core:1.1.0'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
androidTestImplementation 'androidx.multidex:multidex-instrumentation:2.0.0'

我找不到任何证据表明我还需要其他任何东西。

我也在 https://github.com/facebook/screenshot-tests-for-android 上看到过那个

You need python-2.7 for the gradle plugin to work, and we also recommending installing the python-pillow library which is required for recording and verifying screenshots.

我已经安装了它,看到我有 2.7.16 版 我还安装了推荐的枕头 (v6.0.0)

最佳答案

您可能需要移动此行:

apply plugin: "com.facebook.testing.screenshot"

进入模块级别 build.gradle。它必须在这一行以下:

apply plugin: "com.android.application"

因为那是 androidTestImplementation 的来源。

关于android - 为 Facebook screenshot-tests-for-android 设置 gradle 插件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55859478/

相关文章:

java - Android Espresso 拖放错误注入(inject)事件

安卓 Espresso : How to match text on custom spinner selected item layout?

android - IndexAxisValueFormatter 未按预期工作

java - 在 Android 中对图像进行二值化

android - 双存图

android - 关于 Robolectric。当我在 Activity 中有未初始化的对象时,如何测试该 Activity ?

mockito - AndroidViewModel 和单元测试

android - 已更新为Canary 3.0,并且运行时Gradle执行失败

java - 聊天应用程序中的 Firebase 实时数据库无法按时间检索消息

android - Espresso 嵌套 ScrollView