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

Issue setting up the gradle plugin for Facebook screenshot-tests-for-android

我需要为 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 的来源。

文档里没说清楚

行:

classpath 'com.facebook.testing.screenshot:plugin:0.14.0'

进入项目的 gradle 文件 (build.gradle .)

还有一行:

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

进入您应用的 gradle 文件(build.gradle 应用)