11package com.dropbox.affectedmoduledetector
22
3+ import com.dropbox.affectedmoduledetector.rules.SetupAndroidProject
34import com.google.common.truth.Truth.assertThat
45import org.gradle.testkit.runner.GradleRunner
56import org.junit.Rule
67import org.junit.Test
7- import org.junit.rules.TemporaryFolder
88
99class AffectedModuleDetectorIntegrationTest {
1010
1111 @Rule
1212 @JvmField
13- val tmpFolder = TemporaryFolder ()
13+ val tmpFolder = SetupAndroidProject ()
1414
1515 @Test
1616 fun `GIVEN single project WHEN plugin is applied THEN tasks are added` () {
1717 // GIVEN
1818 // expected tasks
1919 val tasks = listOf (
20- " runAffectedUnitTests" ,
21- " runAffectedAndroidTests" ,
22- " assembleAffectedAndroidTests"
20+ " runAffectedUnitTests" ,
21+ " runAffectedAndroidTests" ,
22+ " assembleAffectedAndroidTests"
2323 )
2424 tmpFolder.newFile(" build.gradle" ).writeText(
25- """ plugins {
25+ """ plugins {
2626 | id "com.dropbox.affectedmoduledetector"
2727 |}""" .trimMargin()
2828 )
2929
3030 // WHEN
3131 val result = GradleRunner .create()
32- .withProjectDir(tmpFolder.root)
33- .withPluginClasspath()
34- .withArguments(" tasks" )
35- .build()
32+ .withProjectDir(tmpFolder.root)
33+ .withPluginClasspath()
34+ .withArguments(" tasks" )
35+ .build()
3636
3737 // THEN
3838 tasks.forEach { taskName ->
@@ -43,17 +43,18 @@ class AffectedModuleDetectorIntegrationTest {
4343 @Test
4444 fun `GIVEN multiple project WHEN plugin is applied THEN tasks has dependencies` () {
4545 // GIVEN
46+ tmpFolder.setupAndroidSdkLocation()
4647 tmpFolder.newFolder(" sample-app" )
4748 tmpFolder.newFolder(" sample-core" )
4849 tmpFolder.newFile(" settings.gradle" ).writeText(
49- """
50+ """
5051 |include ':sample-app'
5152 |include ':sample-core'
5253 """ .trimMargin()
5354 )
5455
5556 tmpFolder.newFile(" build.gradle" ).writeText(
56- """ buildscript {
57+ """ buildscript {
5758 | repositories {
5859 | google()
5960 | jcenter()
@@ -75,7 +76,7 @@ class AffectedModuleDetectorIntegrationTest {
7576 )
7677
7778 tmpFolder.newFile(" sample-app/build.gradle" ).writeText(
78- """ plugins {
79+ """ plugins {
7980 | id 'com.android.application'
8081 | id 'kotlin-android'
8182 | }
@@ -89,7 +90,7 @@ class AffectedModuleDetectorIntegrationTest {
8990 )
9091
9192 tmpFolder.newFile(" sample-core/build.gradle" ).writeText(
92- """ plugins {
93+ """ plugins {
9394 | id 'com.android.library'
9495 | id 'kotlin-android'
9596 | }
@@ -104,10 +105,10 @@ class AffectedModuleDetectorIntegrationTest {
104105
105106 // WHEN
106107 val result = GradleRunner .create()
107- .withProjectDir(tmpFolder.root)
108- .withPluginClasspath()
109- .withArguments(" assembleAffectedAndroidTests" , " --dry-run" )
110- .build()
108+ .withProjectDir(tmpFolder.root)
109+ .withPluginClasspath()
110+ .withArguments(" assembleAffectedAndroidTests" , " --dry-run" )
111+ .build()
111112
112113 // THEN
113114 assertThat(result.output).contains(" :sample-app:assembleDebugAndroidTest SKIPPED" )
0 commit comments