android - 为什么 Gradle 会运行两次测试?

标签 android gradle android-gradle-plugin android-testing

如果我以通常的方式运行我的测试,一切都很好。 问题是当我在 gradle 的帮助下运行测试时,它们被执行了两次。我使用 grandle 来分离中小型测试的执行。

这是gradle控制台的数据:

Executing tasks: [connectedAndroidTest]

Configuration on demand is an incubating feature.
Incremental java compilation is an incubating feature.
:app:preBuild UP-TO-DATE
:app:preProductionDebugBuild UP-TO-DATE
:app:checkProductionDebugManifest
:app:preProductionDebugAndroidTestBuild UP-TO-DATE
:app:preProductionReleaseBuild UP-TO-DATE
:app:preUiTestDebugAndroidTestBuild UP-TO-DATE
:app:preUiTestDebugBuild UP-TO-DATE
:app:preUiTestReleaseBuild UP-TO-DATE
:app:prepareComAndroidSupportAnimatedVectorDrawable2421Library UP-TO-DATE
:app:prepareComAndroidSupportAppcompatV72421Library UP-TO-DATE
:app:prepareComAndroidSupportDesign2421Library UP-TO-DATE
:app:prepareComAndroidSupportRecyclerviewV72421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUi2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportCoreUtils2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportFragment2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportMediaCompat2421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42421Library UP-TO-DATE
:app:prepareComAndroidSupportSupportVectorDrawable2421Library UP-TO-DATE
:app:preparePlDroidsonroidsGifAndroidGifDrawable123Library UP-TO-DATE
:app:prepareProductionDebugDependencies
:app:compileProductionDebugAidl UP-TO-DATE
:app:compileProductionDebugRenderscript UP-TO-DATE
:app:generateProductionDebugBuildConfig UP-TO-DATE
:app:generateProductionDebugResValues UP-TO-DATE
:app:generateProductionDebugResources UP-TO-DATE
:app:mergeProductionDebugResources UP-TO-DATE
:app:processProductionDebugManifest UP-TO-DATE
:app:processProductionDebugResources UP-TO-DATE
:app:generateProductionDebugSources UP-TO-DATE
:app:incrementalProductionDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileProductionDebugJavaWithJavac UP-TO-DATE
:app:compileProductionDebugNdk UP-TO-DATE
:app:compileProductionDebugSources UP-TO-DATE
:app:mergeProductionDebugShaders UP-TO-DATE
:app:compileProductionDebugShaders UP-TO-DATE
:app:generateProductionDebugAssets UP-TO-DATE
:app:mergeProductionDebugAssets UP-TO-DATE
:app:transformClassesWithDexForProductionDebug UP-TO-DATE
:app:mergeProductionDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForProductionDebug UP-TO-DATE
:app:processProductionDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForProductionDebug UP-TO-DATE
:app:validateSigningProductionDebug
:app:packageProductionDebug UP-TO-DATE
:app:assembleProductionDebug UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoContrib222Library UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoCore222Library UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoIdlingResource222Library UP-TO-DATE
:app:prepareComAndroidSupportTestEspressoEspressoIntents222Library UP-TO-DATE
:app:prepareComAndroidSupportTestExposedInstrumentationApiPublish05Library UP-TO-DATE
:app:prepareComAndroidSupportTestRules05Library UP-TO-DATE
:app:prepareComAndroidSupportTestRunner05Library UP-TO-DATE
:app:prepareComAndroidSupportTestUiautomatorUiautomatorV18212Library UP-TO-DATE
:app:prepareProductionDebugAndroidTestDependencies
:app:compileProductionDebugAndroidTestAidl UP-TO-DATE
:app:processProductionDebugAndroidTestManifest UP-TO-DATE
:app:compileProductionDebugAndroidTestRenderscript UP-TO-DATE
:app:generateProductionDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateProductionDebugAndroidTestResValues UP-TO-DATE
:app:generateProductionDebugAndroidTestResources UP-TO-DATE
:app:mergeProductionDebugAndroidTestResources UP-TO-DATE
:app:processProductionDebugAndroidTestResources UP-TO-DATE
:app:generateProductionDebugAndroidTestSources UP-TO-DATE
:app:incrementalProductionDebugAndroidTestJavaCompilationSafeguard UP-TO-DATE
:app:compileProductionDebugAndroidTestJavaWithJavac UP-TO-DATE
:app:compileProductionDebugAndroidTestNdk UP-TO-DATE
:app:compileProductionDebugAndroidTestSources UP-TO-DATE
:app:mergeProductionDebugAndroidTestShaders UP-TO-DATE
:app:compileProductionDebugAndroidTestShaders UP-TO-DATE
:app:generateProductionDebugAndroidTestAssets UP-TO-DATE
:app:mergeProductionDebugAndroidTestAssets UP-TO-DATE
:app:transformClassesWithDexForProductionDebugAndroidTest UP-TO-DATE
:app:mergeProductionDebugAndroidTestJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForProductionDebugAndroidTest UP-TO-DATE
:app:processProductionDebugAndroidTestJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForProductionDebugAndroidTest UP-TO-DATE
:app:validateSigningProductionDebugAndroidTest
:app:packageProductionDebugAndroidTest UP-TO-DATE
:app:assembleProductionDebugAndroidTest UP-TO-DATE
:app:connectedProductionDebugAndroidTest
:app:checkUiTestDebugManifest
:app:prepareUiTestDebugDependencies
:app:compileUiTestDebugAidl UP-TO-DATE
:app:compileUiTestDebugRenderscript UP-TO-DATE
:app:generateUiTestDebugBuildConfig UP-TO-DATE
:app:generateUiTestDebugResValues UP-TO-DATE
:app:generateUiTestDebugResources UP-TO-DATE
:app:mergeUiTestDebugResources UP-TO-DATE
:app:processUiTestDebugManifest UP-TO-DATE
:app:processUiTestDebugResources UP-TO-DATE
:app:generateUiTestDebugSources UP-TO-DATE
:app:incrementalUiTestDebugJavaCompilationSafeguard UP-TO-DATE
:app:compileUiTestDebugJavaWithJavac UP-TO-DATE
:app:compileUiTestDebugNdk UP-TO-DATE
:app:compileUiTestDebugSources UP-TO-DATE
:app:mergeUiTestDebugShaders UP-TO-DATE
:app:compileUiTestDebugShaders UP-TO-DATE
:app:generateUiTestDebugAssets UP-TO-DATE
:app:mergeUiTestDebugAssets UP-TO-DATE
:app:transformClassesWithDexForUiTestDebug UP-TO-DATE
:app:mergeUiTestDebugJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForUiTestDebug UP-TO-DATE
:app:processUiTestDebugJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForUiTestDebug UP-TO-DATE
:app:validateSigningUiTestDebug
:app:packageUiTestDebug UP-TO-DATE
:app:assembleUiTestDebug UP-TO-DATE
:app:prepareUiTestDebugAndroidTestDependencies
:app:compileUiTestDebugAndroidTestAidl UP-TO-DATE
:app:processUiTestDebugAndroidTestManifest UP-TO-DATE
:app:compileUiTestDebugAndroidTestRenderscript UP-TO-DATE
:app:generateUiTestDebugAndroidTestBuildConfig UP-TO-DATE
:app:generateUiTestDebugAndroidTestResValues UP-TO-DATE
:app:generateUiTestDebugAndroidTestResources UP-TO-DATE
:app:mergeUiTestDebugAndroidTestResources UP-TO-DATE
:app:processUiTestDebugAndroidTestResources UP-TO-DATE
:app:generateUiTestDebugAndroidTestSources UP-TO-DATE
:app:incrementalUiTestDebugAndroidTestJavaCompilationSafeguard UP-TO-DATE
:app:compileUiTestDebugAndroidTestJavaWithJavac UP-TO-DATE
:app:compileUiTestDebugAndroidTestNdk UP-TO-DATE
:app:compileUiTestDebugAndroidTestSources UP-TO-DATE
:app:mergeUiTestDebugAndroidTestShaders UP-TO-DATE
:app:compileUiTestDebugAndroidTestShaders UP-TO-DATE
:app:generateUiTestDebugAndroidTestAssets UP-TO-DATE
:app:mergeUiTestDebugAndroidTestAssets UP-TO-DATE
:app:transformClassesWithDexForUiTestDebugAndroidTest UP-TO-DATE
:app:mergeUiTestDebugAndroidTestJniLibFolders UP-TO-DATE
:app:transformNative_libsWithMergeJniLibsForUiTestDebugAndroidTest UP-TO-DATE
:app:processUiTestDebugAndroidTestJavaRes UP-TO-DATE
:app:transformResourcesWithMergeJavaResForUiTestDebugAndroidTest UP-TO-DATE
:app:validateSigningUiTestDebugAndroidTest
:app:packageUiTestDebugAndroidTest UP-TO-DATE
:app:assembleUiTestDebugAndroidTest UP-TO-DATE
:app:connectedUiTestDebugAndroidTest
:app:connectedAndroidTest UP-TO-DATE

BUILD SUCCESSFUL

Total time: 19.84 secs

测试在 :app:connectedProductionDebugAndroidTest 和 :app:connectedUiTestDebugAndroidTest 行中执行。

为什么 gradle 会运行两次测试?以及如何避免?

最佳答案

如果您正在执行 connectedAndroidTest,gradle 将自动运行 connected(FlavorName+BuildType)AndroidTest,看起来您有 2 种风格(Production 和 UiTest)。您可能可以只运行这些命令之一,而不是运行 connectedAndroidTest

关于android - 为什么 Gradle 会运行两次测试?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40980978/

相关文章:

java - Eclipse - 无法从 'https://services.gradle.org/distributions/gradle-2.1-bin.zip' 安装 Gradle 发行版

intellij-idea - 如何启动一个简单的Gradle + JavaFX + OSGi应用程序

android - Gradle 4.9 + Lombok 1.18.0 失败

安卓应用 : send post to a user's friend without knowing its id in advance

android - 如何在android中创建并写入xml文件

gradle - gradle如果找不到工件,则解析依赖关系,然后构建依赖关系并上传工件

android - 构建 Signed Android App Bundle 文件时出错。任务 ':app:signReleaseBundle' > 'other' 的执行失败具有不同的根

android - 将签名信息添加到 gradle 中的 apk 文件名

android - fragment 是否保证会调用 onDestroy()?

java - 将对象从父类类型转换为子类