Gradle Espresso - 在根项目中找不到任务 connectedProductFlavorBuildTypeAndroidTest

Gradle Espresso - Task connectedProductFlavorBuildTypeAndroidTest not found in root project

我的build.gradle是这样的:

productFlavors {
        mainFlavor {
            // ...
        }
    }

    buildTypes {
        debug {
             // ...
        }
        buildType1 {// I write mock data classes for Espresso tests here
             // ...
        }
    }

./gradlew tasks 包括 connectedMainFlavorDebugAndroidTest 但不包括 connectedMainFlavorBuildType1AndroidTest.
为什么?

我只想 运行 Espresso 仅针对 buildType1 进行测试。
我不是项目的所有者,我不能使用 mainFlavorDebugsomeNewFlavorDebug 来编写 Espresso 测试

来自official documentation的回答:

By default, all tests run against the debug build type. You can change this to another build type by using the testBuildType property in your module-level build.gradle file. For example, if you want to run your tests against your "staging" build type, edit the file as shown in the following snippet.

android { ... testBuildType "staging" }