我需要为 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/