2016-12-05 88 views
1

如果我按通常的方式运行测试,一切都很好。 问题是,当我运行Gradle的帮助下运行测试时,它们被执行两次。我使用grandle来分离中小型测试的执行。为什么Gradle会运行两次测试?

这是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 

测试是在执行行:应用程序:connectedProductionDebugAndroidTest和:应用程序:connectedUiTestDebugAndroidTest。

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

回答

4

如果您正在执行connectedAndroidTest,gradle将自动运行connected(FlavorName+BuildType)AndroidTest,看起来您有两种口味(Production和UiTest)。您可能只需运行其中一个命令,而不是运行connectedAndroidTest

+0

非常感谢!你可能明白我在Gradle中绝对是零。我有两种形式:productFlavors { 生产{ 的minSdkVersion 15 } uiTest { 的minSdkVersion 18 }} 。这就是为什么Gradle跑两次测试。 – Dmitriy