Android: Skip Gradle “testClasses” task for a dependency project

后端 未结 1 985
误落风尘
误落风尘 2021-02-05 06:56

I have followed this guide to create a JUnit test file for my main Android module (let\'s call it \"module-a\"), in Android Studio v1.4.

My \"module-a\" has a dependency

相关标签:
1条回答
  • 2021-02-05 07:09

    I did not find a way to skip the testClasses task for module-b: it seems that actions started from Android Studio (like running a JUnit test) run Gradle commands that cannot be modified. In my case:

    Information:Gradle: Executing tasks:
    [:module-a:prepareFree_flavorDebugUnitTestDependencies,
     :module-a:generateFree_flavorDebugSources,
     :module-a:mockableAndroidJar,
     :module-a:assembleFree_flavorDebug,
     :module-a:assembleFree_flavorDebugUnitTest,
     :module-b:testClasses]
    

    I found a workaround for my problem, though:

    Add the following code to module-b build.gradle:

    task testClasses {
        doLast {
            println 'This is a dummy testClasses task'
        }
    }
    
    0 讨论(0)
提交回复
热议问题