Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--test-targets param #394

Merged
merged 4 commits into from
Nov 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion test_runner/src/main/kotlin/ftl/args/AndroidArgs.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class AndroidArgs(
val environmentVariables = androidGcloud.environmentVariables
val directoriesToPull = androidGcloud.directoriesToPull
val performanceMetrics = androidGcloud.performanceMetrics
val testTargets = androidGcloud.testTargets
val testTargets = cli.testTargets ?: androidGcloud.testTargets
val devices = androidGcloud.device

private val flank = flankYml.flank
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,11 @@ class AndroidRunCommand : Runnable {
@Option(names = ["--test"], description = ["""The path to the binary file containing instrumentation tests.
|The given path may be in the local filesystem or in Google Cloud Storage using a URL beginning with gs://."""])
var test: String? = null

@Option(names = ["--test-targets"], description = ["""A list of one or more test target filters to apply
(default: run all test targets). Each target filter must be fully qualified with the package name, class name,
or test annotation desired. Any test filter supported by am instrument -e … is supported.
See https://developer.android.com/reference/android/support/test/runner/AndroidJUnitRunner for more
information."""])
var testTargets: List<String>? = null
}
23 changes: 23 additions & 0 deletions test_runner/src/test/kotlin/ftl/args/AndroidArgsTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,27 @@ AndroidArgs
assertThat(androidArgs.testApk).isEqualTo(appApk)
assertThat(androidArgs.cli).isEqualTo(cli)
}

@Test
fun androidArgs_overrideTestTargetsFromCmdLine() {
val cli = AndroidRunCommand()
val testTarget = "class com.foo.ClassName"

CommandLine(cli).parse("--test-targets", testTarget)

val androidArgs = AndroidArgs.load(
"""
gcloud:
app: $appApk
test: $testApk
test-targets:
- class com.example.app.ExampleUiTest#testPasses
- class com.example.app.ExampleUiTest#testFails
""",
cli
)

assertThat(androidArgs.testTargets.size).isEqualTo(1)
assertThat(androidArgs.testTargets).isEqualTo(listOf(testTarget))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class AndroidRunCommandTest {
CommandLine(cmd).parse()
assertThat(cmd.app).isEqualTo(null)
assertThat(cmd.test).isEqualTo(null)
assertThat(cmd.testTargets).isEqualTo(null)
}

@Test
Expand All @@ -74,4 +75,17 @@ class AndroidRunCommandTest {
CommandLine(cmd).parse("--test", "myTestApp.apk")
assertThat(cmd.test).isEqualTo("myTestApp.apk")
}

@Test
fun testTargets_parse() {
val testTargets = "--test-targets"
val params = arrayOf(testTargets, "class com.foo.Clazz", testTargets, "package com.my.package")
val cmd = AndroidRunCommand()

CommandLine(cmd).parse(*params)

assertThat(cmd.testTargets).isNotNull()
assertThat(cmd.testTargets?.size).isEqualTo(2)
assertThat(cmd.testTargets).isEqualTo(params.filter { it != testTargets })
}
}