From 672aae8fabad4dcba65aa9fedd4a38ee7bbb87d2 Mon Sep 17 00:00:00 2001 From: Jared Burrows Date: Sun, 22 Sep 2019 22:34:57 -0700 Subject: [PATCH] remove testing flags --- .../com/jaredsburrows/spoon/SpoonTask.kt | 26 +++++++++---------- .../jaredsburrows/spoon/SpoonTaskSpec.groovy | 5 ---- 2 files changed, 12 insertions(+), 19 deletions(-) diff --git a/src/main/kotlin/com/jaredsburrows/spoon/SpoonTask.kt b/src/main/kotlin/com/jaredsburrows/spoon/SpoonTask.kt index 86d62ff..3c9cae6 100644 --- a/src/main/kotlin/com/jaredsburrows/spoon/SpoonTask.kt +++ b/src/main/kotlin/com/jaredsburrows/spoon/SpoonTask.kt @@ -4,10 +4,10 @@ import com.android.ddmlib.testrunner.IRemoteAndroidTestRunner.TestSize import com.squareup.spoon.SpoonRunner import org.gradle.api.DefaultTask import org.gradle.api.GradleException +import org.gradle.api.Task import org.gradle.api.tasks.TaskAction import java.io.File import java.time.Duration -import org.gradle.api.Task /** A [Task] that creates and runs the Spoon test runner. */ open class SpoonTask : DefaultTask() { // tasks can't be final @@ -17,26 +17,21 @@ open class SpoonTask : DefaultTask() { // tasks can't be final } /** Use our Spoon extension. */ - lateinit var extension: SpoonExtension - + var extension: SpoonExtension = SpoonExtension() /** Application APK (eg. app-debug.apk). */ - lateinit var applicationApk: File - + var applicationApk: File? = null /** Instrumentation APK (eg. app-debug-androidTest.apk). */ - lateinit var instrumentationApk: File - + var instrumentationApk: File? = null /** Results baseOutputDir. */ - lateinit var outputDir: File + var outputDir: File? = null /** TESTING ONLY */ - var testing: Boolean = false - var testValue: Boolean = true var spoonRenderer: SpoonRunner.Builder? = null @Suppress("unused") @TaskAction fun spoonTask() { - if (extension.className.isEmpty() && extension.methodName.isNotEmpty()) { + if (extension.className.isEmpty() and extension.methodName.isNotEmpty()) { throw IllegalStateException("'${extension.methodName}' must have a fully qualified class " + "name.") } @@ -59,8 +54,10 @@ open class SpoonTask : DefaultTask() { // tasks can't be final .setClearAppDataBeforeEachTest(extension.clearAppDataBeforeEachTest) // APKs - if (!testing) { + instrumentationApk?.let { builder.setTestApk(instrumentationApk) + } + applicationApk?.let { builder.addOtherApk(applicationApk) } @@ -116,8 +113,9 @@ open class SpoonTask : DefaultTask() { // tasks can't be final spoonRenderer = builder - val success = if (testing) testValue else builder.build().run() - if (!success && !extension.ignoreFailures) { + builder.build().run() + + if (!extension.ignoreFailures) { throw GradleException("Tests failed! " + "See ${ConsoleRenderer.asClickableFileUrl(File(outputDir, "index.html"))}") } diff --git a/src/test/groovy/com/jaredsburrows/spoon/SpoonTaskSpec.groovy b/src/test/groovy/com/jaredsburrows/spoon/SpoonTaskSpec.groovy index dd813d7..b39a4af 100644 --- a/src/test/groovy/com/jaredsburrows/spoon/SpoonTaskSpec.groovy +++ b/src/test/groovy/com/jaredsburrows/spoon/SpoonTaskSpec.groovy @@ -54,7 +54,6 @@ final class SpoonTaskSpec extends Specification { project.evaluate() SpoonTask task = project.tasks.getByName(taskName) as SpoonTask - task.testing = true task.applicationApk = appApk task.instrumentationApk = testApk task.execute() @@ -146,7 +145,6 @@ final class SpoonTaskSpec extends Specification { project.evaluate() SpoonTask task = project.tasks.getByName(taskName) as SpoonTask - task.testing = true task.applicationApk = appApk task.instrumentationApk = testApk task.execute() @@ -248,7 +246,6 @@ final class SpoonTaskSpec extends Specification { project.evaluate() SpoonTask task = project.tasks.getByName(taskName) as SpoonTask - task.testing = true task.applicationApk = testApk task.instrumentationApk = testApk task.execute() @@ -348,8 +345,6 @@ final class SpoonTaskSpec extends Specification { project.evaluate() SpoonTask task = project.tasks.getByName(taskName) as SpoonTask - task.testing = true - task.testValue = false task.applicationApk = appApk task.instrumentationApk = testApk task.execute()