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

时间:2016-12-05 18:33:33

标签: android gradle android-gradle 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运行测试两次?以及如何避免它?

2 个答案:

答案 0 :(得分:4)

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

答案 1 :(得分:0)

我只有一种口味app,命令是 gradlew :app:connectedDebugAndroidTest -Pandroid.testInstrumentationRunnerArguments.annotation=com.hello.work.annotation.Smoke,但 gradlew 也会运行两次测试用例。

相关问题