// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.3.21' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.5.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } // we need to remove the extra argument otherwise it will throw error since gradle will not recognized // to run this specific test for module app ./gradlew :app:testDebugUnitTest --robolectric // to run for all modules ./gradlew testDebugUnitTest --robolectric // make sure --robolectric is the first argument. if (project.gradle.startParameter?.taskRequests?.args[0]?.remove("--robolectric")) { for (Project project : subprojects) { project.tasks .withType(Test) .configureEach { useJUnit { includeCategories 'com.dexterapps.testsharding.RobolectricTests' //excludeCategories if we want to exclude any test } } } } // to run this specific test ./gradlew :app:testDebugUnitTest --unit else if (project.gradle.startParameter?.taskRequests?.args[0]?.remove("--unit")) { for (Project project : subprojects) { project.tasks .withType(Test) .configureEach { useJUnit { includeCategories 'com.dexterapps.testsharding.UnitTests' //excludeCategories if we want to exclude any test } } } } // to run this specific test ./gradlew :app:testDebugUnitTest --fasttest else if (project.gradle.startParameter?.taskRequests?.args[0]?.remove("--fasttest")) { for (Project project : subprojects) { project.tasks .withType(Test) .configureEach { useJUnit { includeCategories 'com.dexterapps.testsharding.FastTests' //excludeCategories if we want to exclude any test } } } } // if we want to add sharding in just some modules then add this in that modules build.gradle // replace "app" with module name. /* if (project.gradle.startParameter?.taskRequests?.args[0]?.remove("--robolectric")) { subprojects .find { it.name == "app" } .tasks .withType(Test) .configureEach { useJUnit { includeCategories 'com.dexterapps.testsharding.RobolectricTests' //excludeCategories if we want to exclude any test } } } */ task clean(type: Delete) { delete rootProject.buildDir }