Skip to content

Commit

Permalink
Make Android tests more specific (detekt#6988)
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex authored Feb 23, 2024
1 parent 929f28e commit 3018791
Showing 1 changed file with 107 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,13 @@ class DetektAndroidSpec {
assertThat(buildResult.output).contains("--report xml:")
assertThat(buildResult.output).contains("--report sarif:")
assertThat(buildResult.output).doesNotContain("--report txt:")
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":app:detekt") }
.containsExactlyInAnyOrder(
":app:detektDebug",
":app:detektMain",
":app:detektDebug"
":app:detektRelease",
)
)
}
}

Expand Down Expand Up @@ -100,12 +101,14 @@ class DetektAndroidSpec {
assertThat(buildResult.output).contains("--report xml:")
assertThat(buildResult.output).contains("--report sarif:")
assertThat(buildResult.output).doesNotContain("--report txt:")
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":app:detekt") }
.containsExactlyInAnyOrder(
":app:detektDebugAndroidTest",
":app:detektDebugUnitTest",
":app:detektDebugAndroidTest"
":app:detektReleaseUnitTest",
":app:detektTest",
)
)
}
}
}
Expand Down Expand Up @@ -191,12 +194,13 @@ class DetektAndroidSpec {
assertThat(buildResult.output).contains("--report xml:")
assertThat(buildResult.output).contains("--report sarif:")
assertThat(buildResult.output).doesNotContain("--report txt:")
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektDebug",
":lib:detektMain",
":lib:detektDebug"
":lib:detektRelease",
)
)
}
}

Expand All @@ -216,12 +220,14 @@ class DetektAndroidSpec {
assertThat(buildResult.output).contains("--report xml:")
assertThat(buildResult.output).contains("--report sarif:")
assertThat(buildResult.output).doesNotContain("--report txt:")
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektDebugAndroidTest",
":lib:detektDebugUnitTest",
":lib:detektDebugAndroidTest"
":lib:detektReleaseUnitTest",
":lib:detektTest",
)
)
}
}
}
Expand Down Expand Up @@ -289,11 +295,13 @@ class DetektAndroidSpec {
assertThat(buildResult.output).contains("--report xml:")
assertThat(buildResult.output).contains("--report sarif:")
assertThat(buildResult.output).doesNotContain("--report txt:")
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":android_lib:detekt") }
.containsExactlyInAnyOrder(
":android_lib:detektDebug",
":android_lib:detektMain",
":android_lib:detektRelease",
)
)
}
}

Expand All @@ -314,11 +322,14 @@ class DetektAndroidSpec {
assertThat(buildResult.output).contains("--report xml:")
assertThat(buildResult.output).contains("--report sarif:")
assertThat(buildResult.output).doesNotContain("--report txt:")
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":android_lib:detekt") }
.containsExactlyInAnyOrder(
":android_lib:detektDebugAndroidTest",
":android_lib:detektDebugUnitTest",
":android_lib:detektReleaseUnitTest",
":android_lib:detektTest",
)
)
}
}
}
Expand Down Expand Up @@ -347,29 +358,33 @@ class DetektAndroidSpec {
@DisplayName("task :lib:detektMain")
fun libDetektMain() {
gradleRunner.runTasksAndCheckResult(":lib:detektMain") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
":lib:detektYoungHarryDebug",
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektMain",
":lib:detektOldHarryDebug",
":lib:detektOldHarryRelease"
":lib:detektOldHarryRelease",
":lib:detektYoungHarryDebug",
":lib:detektYoungHarryRelease",
)
)
}
}

@Test
@DisplayName("task :lib:detektTest")
fun libDetektTest() {
gradleRunner.runTasksAndCheckResult(":lib:detektTest") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
":lib:detektYoungHarryDebugUnitTest",
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektOldHarryDebugAndroidTest",
":lib:detektOldHarryDebugUnitTest",
":lib:detektOldHarryReleaseUnitTest",
":lib:detektTest",
":lib:detektYoungHarryDebugAndroidTest",
":lib:detektOldHarryDebugAndroidTest"
":lib:detektYoungHarryDebugUnitTest",
":lib:detektYoungHarryReleaseUnitTest",
)
)
}
}
}
Expand Down Expand Up @@ -402,31 +417,37 @@ class DetektAndroidSpec {
@DisplayName("task :lib:detektMain")
fun libDetektMain() {
gradleRunner.runTasksAndCheckResult(":lib:detektMain") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektMain",
":lib:detektOldHarryDebug",
":lib:detektYoungHarryDebug",
":lib:detektOldHarryDebug"
)
).doesNotContain(
":lib:detektOldHarryRelease"
)
.doesNotContain(
":lib:detektOldHarryRelease",
":lib:detektYoungHarryRelease",
)
}
}

@Test
@DisplayName("task :lib:detektTest")
fun libDetektTest() {
gradleRunner.runTasksAndCheckResult(":lib:detektTest") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
":lib:detektYoungHarryDebugUnitTest",
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektOldHarryDebugAndroidTest",
":lib:detektOldHarryDebugUnitTest",
":lib:detektTest",
":lib:detektYoungHarryDebugAndroidTest",
":lib:detektOldHarryDebugAndroidTest"
":lib:detektYoungHarryDebugUnitTest",
)
.doesNotContain(
":lib:detektOldHarryReleaseUnitTest",
":lib:detektYoungHarryReleaseUnitTest",
)
).doesNotContain(
":lib:detektOldHarryReleaseUnitTest"
)
}
}
}
Expand Down Expand Up @@ -459,31 +480,37 @@ class DetektAndroidSpec {
@DisplayName("task :lib:detektMain")
fun libDetektMain() {
gradleRunner.runTasksAndCheckResult(":lib:detektMain") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
":lib:detektOldHarryDebug"
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektMain",
":lib:detektOldHarryDebug",
":lib:detektYoungHarryRelease",
)
.doesNotContain(
":lib:detektOldHarryRelease",
":lib:detektYoungHarryDebug",
)
).doesNotContain(
":lib:detektYoungHarryDebug",
":lib:detektOldHarryRelease"
)
}
}

@Test
@DisplayName("task :lib:detektTest")
fun libDetektTest() {
gradleRunner.runTasksAndCheckResult(":lib:detektTest") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektOldHarryDebugAndroidTest",
":lib:detektOldHarryDebugUnitTest",
":lib:detektOldHarryDebugAndroidTest"
":lib:detektTest",
":lib:detektYoungHarryReleaseUnitTest",
)
.doesNotContain(
":lib:detektOldHarryReleaseUnitTest",
":lib:detektYoungHarryDebugAndroidTest",
":lib:detektYoungHarryDebugUnitTest",
)
).doesNotContain(
":lib:detektYoungHarryDebugUnitTest",
":lib:detektYoungHarryDebugAndroidTest",
":lib:detektOldHarryReleaseUnitTest"
)
}
}
}
Expand Down Expand Up @@ -516,31 +543,37 @@ class DetektAndroidSpec {
@DisplayName("task :lib:detektMain")
fun libDetektMain() {
gradleRunner.runTasksAndCheckResult(":lib:detektMain") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektMain",
":lib:detektOldHarryDebug",
":lib:detektOldHarryRelease"
":lib:detektOldHarryRelease",
)
.doesNotContain(
":lib:detektYoungHarryDebug",
":lib:detektYoungHarryRelease",
)
).doesNotContain(
":lib:detektYoungHarryDebug"
)
}
}

@Test
@DisplayName("task :lib:detektTest")
fun libDetektTest() {
gradleRunner.runTasksAndCheckResult(":lib:detektTest") { buildResult ->
assertThat(buildResult.tasks.map { it.path }).containsAll(
listOf(
":lib:detektOldHarryDebugUnitTest",
assertThat(buildResult.tasks.map { it.path })
.filteredOn { it.startsWith(":lib:detekt") }
.containsExactlyInAnyOrder(
":lib:detektOldHarryDebugAndroidTest",
":lib:detektOldHarryReleaseUnitTest"
":lib:detektOldHarryDebugUnitTest",
":lib:detektOldHarryReleaseUnitTest",
":lib:detektTest",
)
.doesNotContain(
":lib:detektYoungHarryDebugAndroidTest",
":lib:detektYoungHarryDebugUnitTest",
":lib:detektYoungHarryReleaseUnitTest",
)
).doesNotContain(
":lib:detektYoungHarryDebugUnitTest",
":lib:detektYoungHarryDebugAndroidTest"
)
}
}

Expand Down

0 comments on commit 3018791

Please sign in to comment.