Skip to content

Commit 3c6d887

Browse files
authored
[KotlinTest] Start porting tests to Kotlin, port TestUtils (#59)
This sets up the compilation paths and moves the TestUtils class to Kotlin. Including a single test as a PoC. First part of #58
1 parent bb3dbe2 commit 3c6d887

File tree

13 files changed

+285
-283
lines changed

13 files changed

+285
-283
lines changed

build.gradle.kts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,14 @@ dependencies {
7878
testImplementation("org.assertj:assertj-core:3.24.2")
7979
}
8080

81+
tasks.compileTestGroovy {
82+
classpath += files(tasks.compileTestKotlin.flatMap { it.destinationDirectory })
83+
}
84+
85+
tasks.testClasses {
86+
dependsOn(tasks.compileTestGroovy)
87+
}
88+
8189
tasks.check {
8290
dependsOn(tasks.named("projectHealth"))
8391
}

src/test/groovy/org/assertj/generator/gradle/IncrementalBuild.groovy

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ class IncrementalBuild {
3737
@Rule
3838
public final TemporaryFolder testProjectDir = new TemporaryFolder()
3939

40-
File buildFile
4140
private Path srcPackagePath
4241
private Path packagePath
4342
private File h1Java
4443
private File h2Java
4544

4645
@Before
4746
void setup() {
48-
buildFile = testProjectDir.newFile('build.gradle')
47+
def buildFile = testProjectDir.newFile('build.gradle')
48+
TestUtils.writeDefaultBuildFile(buildFile)
4949

5050
File srcDir = testProjectDir.newFolder('src', 'main', 'java')
5151

@@ -100,12 +100,6 @@ class IncrementalBuild {
100100

101101
@Test
102102
void incremental_build_does_not_rebuild_everything() {
103-
TestUtils.buildFile(buildFile, """
104-
sourceSets {
105-
main { assertJ {} }
106-
}
107-
""")
108-
109103
def runner = GradleRunner.create()
110104
.withProjectDir(testProjectDir.root)
111105
.withDebug(true)
@@ -128,12 +122,6 @@ class IncrementalBuild {
128122

129123
@Test
130124
void incremental_build_rebuild_changed_single_file_contents() {
131-
TestUtils.buildFile(buildFile, """
132-
sourceSets {
133-
main { assertJ {} }
134-
}
135-
""")
136-
137125
def runner = GradleRunner.create()
138126
.withProjectDir(testProjectDir.root)
139127
.withDebug(true)

src/test/groovy/org/assertj/generator/gradle/SimpleBuild.groovy

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

src/test/groovy/org/assertj/generator/gradle/SkipPackageInfo.groovy

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ class SkipPackageInfo {
3232
@Rule
3333
public final TemporaryFolder testProjectDir = new TemporaryFolder()
3434

35-
File buildFile
36-
Path generatedPackagePath
35+
private Path generatedPackagePath
3736

3837
@Before
3938
void setup() {
40-
buildFile = testProjectDir.newFile('build.gradle')
39+
def buildFile = testProjectDir.newFile('build.gradle')
40+
TestUtils.writeDefaultBuildFile(buildFile)
4141

4242
File srcDir = testProjectDir.newFolder('src', 'main', 'java')
4343

@@ -112,12 +112,6 @@ class SkipPackageInfo {
112112

113113
@Test
114114
void does_not_include_package_info_file() {
115-
TestUtils.buildFile(buildFile, """
116-
sourceSets {
117-
main { assertJ {} }
118-
}
119-
""")
120-
121115
def result = GradleRunner.create()
122116
.withProjectDir(testProjectDir.root)
123117
.withDebug(true)

src/test/groovy/org/assertj/generator/gradle/TestUtils.groovy

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

src/test/groovy/org/assertj/generator/gradle/parameter/EntryPointGeneration.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class EntryPointGeneration {
8282

8383
@Test
8484
void change_generate_from_sourceSet() {
85-
TestUtils.buildFile(buildFile, """
85+
TestUtils.writeBuildFile(buildFile, """
8686
sourceSets {
8787
main {
8888
assertJ {
@@ -124,7 +124,7 @@ class EntryPointGeneration {
124124
@Test
125125
void change_generate_from_global() {
126126

127-
TestUtils.buildFile(buildFile, """
127+
TestUtils.writeBuildFile(buildFile, """
128128
sourceSets {
129129
main {
130130
assertJ {
@@ -162,7 +162,7 @@ class EntryPointGeneration {
162162

163163
@Test
164164
void change_entry_point_package() {
165-
TestUtils.buildFile(buildFile, """
165+
TestUtils.writeBuildFile(buildFile, """
166166
sourceSets {
167167
main {
168168
assertJ {
@@ -199,7 +199,7 @@ class EntryPointGeneration {
199199

200200
@Test
201201
void change_entry_point_package_and_entry_points() {
202-
TestUtils.buildFile(buildFile, """
202+
TestUtils.writeBuildFile(buildFile, """
203203
sourceSets {
204204
main {
205205
assertJ {

src/test/groovy/org/assertj/generator/gradle/parameter/OutputDirectoryParameter.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import java.nio.file.Path
2424
import java.nio.file.Paths
2525

2626
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat
27-
import static org.assertj.generator.gradle.TestUtils.buildFile
27+
import static org.assertj.generator.gradle.TestUtils.writeBuildFile
2828

2929
/**
3030
* Checks the behaviour of overriding globals in a project
@@ -63,7 +63,7 @@ class OutputDirectoryParameter {
6363

6464
@Test
6565
void change_output_dir_locally() {
66-
buildFile(buildFile, """
66+
writeBuildFile(buildFile, """
6767
sourceSets {
6868
main {
6969
assertJ {

0 commit comments

Comments
 (0)