Skip to content

Commit 9680865

Browse files
committed
Upgrade testing dependencies
1 parent 3a4576e commit 9680865

File tree

3 files changed

+38
-39
lines changed

3 files changed

+38
-39
lines changed

build.gradle.kts

+8-1
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ java {
1212
}
1313

1414
dependencies {
15-
testImplementation(libs.junit)
15+
testImplementation(libs.junit.jupiter)
1616
testImplementation(libs.assertj.core)
17+
testRuntimeOnly(libs.junit.platform.launcher)
1718
}
1819

1920
repositories {
@@ -25,6 +26,12 @@ tasks.withType<AbstractArchiveTask>().configureEach {
2526
isReproducibleFileOrder = true
2627
}
2728

29+
30+
31+
tasks.named<Test>("test") {
32+
useJUnitPlatform()
33+
}
34+
2835
group = "io.fuchs.gradle.classpath-collision-detector"
2936
version = "0.3"
3037

gradle/libs.versions.toml

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
[versions]
2-
junit = "4.13.2"
3-
assertj = "3.23.1"
2+
junit = "5.10.2"
3+
junit-platform-launcher = "1.10.2"
4+
assertj = "3.25.3"
45
plugin-publish = "1.2.1"
56

67
[libraries]
7-
junit = { module = "junit:junit", version.ref = "junit" }
8+
junit-jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" }
9+
junit-platform-launcher = { module = "org.junit.platform:junit-platform-launcher", version.ref = "junit-platform-launcher" }
810
assertj-core = { module = "org.assertj:assertj-core", version.ref = "assertj" }
911

1012
[plugins]

src/test/kotlin/io/fuchs/gradle/collisiondetector/testkit/CollisionDetectorPluginTest.kt

+25-35
Original file line numberDiff line numberDiff line change
@@ -2,59 +2,51 @@ package io.fuchs.gradle.collisiondetector.testkit
22

33
import org.gradle.testkit.runner.GradleRunner
44
import org.gradle.testkit.runner.TaskOutcome
5-
import org.junit.Assert.assertEquals
6-
import org.junit.Rule
7-
import org.junit.Test
8-
import org.junit.rules.TemporaryFolder
5+
import org.junit.jupiter.api.Assertions.assertEquals
6+
import org.junit.jupiter.api.Test
7+
import org.junit.jupiter.api.io.TempDir
8+
import java.nio.file.Path
99

1010
class CollisionDetectorPluginTest {
1111

12-
@get:Rule
13-
val temporaryFolder = TemporaryFolder()
14-
15-
1612
@Test
17-
fun `plugin applies without error`() {
18-
copyBuildFileToTempDir("apply_plugin_only.gradle")
13+
fun `plugin applies without error`(@TempDir tempDir: Path) {
14+
copyBuildFileToTempDir("apply_plugin_only.gradle", tempDir)
1915

2016
GradleRunner.create()
21-
.withProjectDir(temporaryFolder.root)
22-
.withTestKitDir(temporaryFolder.newFolder())
17+
.withProjectDir(tempDir.toFile())
2318
.withPluginClasspath()
2419
.build()
2520
}
2621

2722
@Test
28-
fun `plugin applies without error on minimal supported Gradle version`() {
29-
copyBuildFileToTempDir("apply_plugin_only.gradle")
23+
fun `plugin applies without error on minimal supported Gradle version`(@TempDir tempDir: Path) {
24+
copyBuildFileToTempDir("apply_plugin_only.gradle", tempDir)
3025

3126
GradleRunner.create()
32-
.withProjectDir(temporaryFolder.root)
33-
.withTestKitDir(temporaryFolder.newFolder())
27+
.withProjectDir(tempDir.toFile())
3428
.withPluginClasspath()
3529
.withGradleVersion("6.6.1")
3630
.build()
3731
}
3832

3933
@Test
40-
fun `task is compatible with configuration cache`() {
41-
copyBuildFileToTempDir("apply_plugin_only.gradle")
34+
fun `task is compatible with configuration cache`(@TempDir tempDir: Path) {
35+
copyBuildFileToTempDir("apply_plugin_only.gradle", tempDir)
4236

4337
GradleRunner.create()
44-
.withProjectDir(temporaryFolder.root)
45-
.withTestKitDir(temporaryFolder.newFolder())
38+
.withProjectDir(tempDir.toFile())
4639
.withPluginClasspath()
4740
.withArguments(":detectCollisions", "--configuration-cache")
4841
.build()
4942
}
5043

5144
@Test
52-
fun `task detects no collision`() {
53-
copyBuildFileToTempDir("apply_plugin_only.gradle")
45+
fun `task detects no collision`(@TempDir tempDir: Path) {
46+
copyBuildFileToTempDir("apply_plugin_only.gradle", tempDir)
5447

5548
val buildResult = GradleRunner.create()
56-
.withProjectDir(temporaryFolder.root)
57-
.withTestKitDir(temporaryFolder.newFolder())
49+
.withProjectDir(tempDir.toFile())
5850
.withPluginClasspath()
5951
.withArguments(":detectCollisions")
6052
.build()
@@ -64,12 +56,11 @@ class CollisionDetectorPluginTest {
6456
}
6557

6658
@Test
67-
fun `detects collisions and fails`() {
68-
copyBuildFileToTempDir("found_collisions.gradle")
59+
fun `detects collisions and fails`(@TempDir tempDir: Path) {
60+
copyBuildFileToTempDir("found_collisions.gradle", tempDir)
6961

7062
val buildResult = GradleRunner.create()
71-
.withProjectDir(temporaryFolder.root)
72-
.withTestKitDir(temporaryFolder.newFolder())
63+
.withProjectDir(tempDir.toFile())
7364
.withPluginClasspath()
7465
.withArguments(":detectCollisions")
7566
.buildAndFail()
@@ -79,12 +70,11 @@ class CollisionDetectorPluginTest {
7970
}
8071

8172
@Test
82-
fun `all collisions are ignored`() {
83-
copyBuildFileToTempDir("ignored_collisions.gradle")
73+
fun `all collisions are ignored`(@TempDir tempDir: Path) {
74+
copyBuildFileToTempDir("ignored_collisions.gradle", tempDir)
8475

8576
val buildResult = GradleRunner.create()
86-
.withProjectDir(temporaryFolder.root)
87-
.withTestKitDir(temporaryFolder.newFolder())
77+
.withProjectDir(tempDir.toFile())
8878
.withPluginClasspath()
8979
.withArguments(":detectCollisions")
9080
.build()
@@ -93,11 +83,11 @@ class CollisionDetectorPluginTest {
9383
assertEquals(TaskOutcome.SUCCESS, detectCollisionsTask?.outcome)
9484
}
9585

96-
private fun copyBuildFileToTempDir(buildFile: String) {
97-
val file = temporaryFolder.newFile("build.gradle")
86+
private fun copyBuildFileToTempDir(buildFile: String, tempDir: Path) {
87+
val file = tempDir.resolve("build.gradle").toFile()
9888
ClassLoader.getSystemResourceAsStream(buildFile).use { inputStream ->
9989
file.outputStream().use { inputStream.copyTo(it) }
10090
}
10191
}
10292

103-
}
93+
}

0 commit comments

Comments
 (0)