Skip to content

Commit 96a4b9e

Browse files
author
Marcel Schnelle
authored
Remove Groovy test code & move everything to Kotlin (#136)
1 parent db25fd0 commit 96a4b9e

File tree

20 files changed

+402
-490
lines changed

20 files changed

+402
-490
lines changed

.idea/runConfigurations/Instrumentation_Library__Run_Unit_Tests__IDE_.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.idea/runConfigurations/Instrumentation_Runner__Run_Unit_Tests__IDE_.xml

Lines changed: 0 additions & 21 deletions
This file was deleted.

.idea/runConfigurations/Sample__Run_Unit_Tests__IDE_.xml

Lines changed: 0 additions & 15 deletions
This file was deleted.

android-junit5-tests/build.gradle.kts

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,31 @@ val compileTestGroovy = tasks.getByName("compileTestGroovy") as AbstractCompile
2525
val compileTestKotlin = tasks.getByName("compileTestKotlin") as AbstractCompile
2626
val testClassesTask = tasks.getByName("testClasses")
2727

28-
compileTestGroovy.dependsOn.remove("compileTestJava")
29-
compileTestKotlin.dependsOn.add(compileTestGroovy)
30-
compileTestKotlin.classpath += project.files(compileTestGroovy.destinationDir)
31-
testClassesTask.dependsOn.add(compileTestKotlin)
28+
compileTestKotlin.dependsOn.remove("compileTestJava")
29+
compileTestGroovy.dependsOn.add(compileTestKotlin)
30+
compileTestGroovy.classpath += project.files(compileTestKotlin.destinationDir)
3231

3332
// Add custom dependency configurations
3433
configurations {
3534
create("functionalTest") {
3635
description = "Local dependencies used for compiling & running " +
3736
"tests source code in Gradle functional tests"
3837
}
38+
39+
create("functionalTestAgp32X") {
40+
description = "Local dependencies used for compiling & running " +
41+
"tests source code in Gradle functional tests against AGP 3.2.X"
42+
}
43+
44+
create("functionalTestAgp33X") {
45+
description = "Local dependencies used for compiling & running " +
46+
"tests source code in Gradle functional tests against AGP 3.3.X"
47+
}
48+
49+
create("functionalTestAgp34X") {
50+
description = "Local dependencies used for compiling & running " +
51+
"tests source code in Gradle functional tests against AGP 3.4.X"
52+
}
3953
}
4054

4155
val processTestResources = tasks.getByName("processTestResources") as Copy
@@ -82,15 +96,24 @@ dependencies {
8296
testImplementation(extra["libs.mockito"] as String)
8397

8498
testRuntimeOnly(extra["libs.junitJupiterEngine"] as String)
99+
testRuntimeOnly(extra["libs.junitVintageEngine"] as String)
85100
testRuntimeOnly(extra["libs.spekEngine"] as String)
86101

87102
// Compilation of local classpath for functional tests
88103
val functionalTest by configurations
89104
functionalTest(kotlin("compiler-embeddable", extra["versions.kotlin"] as String))
90105
functionalTest(extra["libs.junit4"] as String)
91-
functionalTest(extra["plugins.android"] as String)
92106
functionalTest(extra["libs.junitJupiterApi"] as String)
93107
functionalTest(extra["libs.junitJupiterEngine"] as String)
108+
109+
val functionalTestAgp32X by configurations
110+
functionalTestAgp32X(extra["plugins.android.32X"] as String)
111+
112+
val functionalTestAgp33X by configurations
113+
functionalTestAgp33X(extra["plugins.android.33X"] as String)
114+
115+
val functionalTestAgp34X by configurations
116+
functionalTestAgp34X(extra["plugins.android.34X"] as String)
94117
}
95118

96119
// Resource Writers
@@ -100,10 +123,13 @@ tasks.create("writePluginClasspath", WriteClasspathResource::class) {
100123
resourceFileName = "plugin-classpath.txt"
101124
}
102125

103-
tasks.create("writeFunctionalTestCompileClasspath", WriteClasspathResource::class) {
104-
inputFiles = configurations["functionalTest"]
105-
outputDir = File("$buildDir/resources/test")
106-
resourceFileName = "functional-test-compile-classpath.txt"
126+
// Create a classpath-generating task for all functional test configurations
127+
listOf("functionalTest", "functionalTestAgp32X", "functionalTestAgp33X", "functionalTestAgp34X").forEach { config ->
128+
tasks.create("write${config.capitalize()}CompileClasspath", WriteClasspathResource::class) {
129+
inputFiles = configurations[config]
130+
outputDir = File("$buildDir/resources/test")
131+
resourceFileName = "$config-compile-classpath.txt"
132+
}
107133
}
108134

109135
val testTask = tasks.getByName("test")

android-junit5-tests/src/test/groovy/de/mannodermaus/gradle/plugins/junit5/DslGroovyTests.groovy

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,36 @@
11
package de.mannodermaus.gradle.plugins.junit5
22

3-
import de.mannodermaus.gradle.plugins.junit5.util.TestEnvironment
4-
import de.mannodermaus.gradle.plugins.junit5.util.TestProjectFactory
3+
import de.mannodermaus.gradle.plugins.junit5.util.TestEnvironment2
4+
import de.mannodermaus.gradle.plugins.junit5.util.TestProjectFactory2
55
import kotlin.io.FilesKt
66
import org.gradle.api.Project
77
import org.gradle.api.tasks.testing.Test
8-
import org.junit.jupiter.api.AfterEach
9-
import org.junit.jupiter.api.BeforeEach
10-
import org.junit.jupiter.api.DisplayName
8+
import org.junit.After
9+
import org.junit.Before
1110

1211
import static org.assertj.core.api.Assertions.assertThat
1312

1413
class DslGroovyTests {
1514

16-
private TestProjectFactory factory
15+
private TestProjectFactory2 factory
1716
private Project testRoot
1817

19-
@BeforeEach
18+
@Before
2019
void beforeEach() {
21-
def environment = new TestEnvironment()
20+
def environment = new TestEnvironment2()
2221

23-
this.factory = new TestProjectFactory(environment)
22+
this.factory = new TestProjectFactory2(environment)
2423
this.testRoot = factory.newRootProject()
2524
}
2625

27-
@AfterEach
26+
@After
2827
void afterEach() {
2928
FilesKt.deleteRecursively(this.testRoot.rootDir)
3029
}
3130

32-
@org.junit.jupiter.api.Test
33-
@DisplayName("dynamic filters methods can be called on existing build types")
31+
@org.junit.Test
3432
void dynamicFiltersMethodsCanBeCalledOnExistingBuildTypes() {
35-
def project = factory.newProject(testRoot)
33+
def project = factory.newProject(testRoot, null)
3634
.asAndroidApplication()
3735
.build()
3836

@@ -57,10 +55,9 @@ class DslGroovyTests {
5755
assertThat(releaseTask.testFramework.options.excludeTags).containsOnly("other-tag")
5856
}
5957

60-
@org.junit.jupiter.api.Test
61-
@DisplayName("dynamic filters methods can be called on existing product flavors")
58+
@org.junit.Test
6259
void dynamicFiltersMethodsCanBeCalledOnExistingProductFlavors() {
63-
def project = factory.newProject(testRoot)
60+
def project = factory.newProject(testRoot, null)
6461
.asAndroidApplication()
6562
.build()
6663

@@ -114,10 +111,9 @@ class DslGroovyTests {
114111
assertThat(paidReleaseTask.testFramework.options.excludeTags).containsOnly("other-tag")
115112
}
116113

117-
@org.junit.jupiter.api.Test
118-
@DisplayName("complex example with multiple flavor dimensions & build types")
114+
@org.junit.Test
119115
void complexExampleWithMultipleFlavorDimensionsAndBuildTypes() {
120-
def project = factory.newProject(testRoot)
116+
def project = factory.newProject(testRoot, null)
121117
.asAndroidApplication()
122118
.build()
123119

android-junit5-tests/src/test/groovy/de/mannodermaus/gradle/plugins/junit5/util/ClasspathSplitter.groovy

Lines changed: 0 additions & 11 deletions
This file was deleted.

android-junit5-tests/src/test/groovy/de/mannodermaus/gradle/plugins/junit5/util/FileLanguage.groovy

Lines changed: 0 additions & 18 deletions
This file was deleted.

android-junit5-tests/src/test/groovy/de/mannodermaus/gradle/plugins/junit5/util/TestEnvironment.groovy

Lines changed: 0 additions & 131 deletions
This file was deleted.

0 commit comments

Comments
 (0)