Skip to content

Commit cffb94d

Browse files
committed
Use Gradle text fixtures to replace our custom testkit sourceset
1 parent f53ed02 commit cffb94d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+28
-46
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test:
1616
acceptance: ENV=test
1717
acceptance:
1818
@echo "Running acceptance tests of version ${VERSION} in ${ENV} environment..."
19-
@./gradlew acceptanceTest -Penv=${ENV}
19+
@./gradlew server:acceptanceTest -Penv=${ENV}
2020

2121
build: ENV=test
2222
build:

buildSrc/src/main/kotlin/kickstart.gradle.kts

+9-29
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

44
plugins {
55
kotlin("jvm")
6+
id("java-test-fixtures")
67
}
78

89
val buildNumber by extra("0")
@@ -25,29 +26,9 @@ tasks.withType<KotlinCompile> {
2526
}
2627
}
2728

28-
sourceSets {
29-
create("testkit") {
30-
compileClasspath += sourceSets.main.get().output
31-
runtimeClasspath += sourceSets.main.get().output
32-
}
33-
}
34-
35-
val testkit by configurations.creating {
36-
isCanBeResolved = false
37-
isCanBeConsumed = true
38-
}
39-
40-
val testkitImplementation by configurations.getting { extendsFrom(configurations.implementation.get()) }
41-
configurations["testImplementation"].extendsFrom(testkitImplementation)
42-
43-
sourceSets.test {
44-
compileClasspath += sourceSets["testkit"].output
45-
runtimeClasspath += sourceSets["testkit"].output
46-
}
47-
4829
val acceptance by sourceSets.creating {
49-
compileClasspath += sourceSets.main.get().output + sourceSets["testkit"].output
50-
runtimeClasspath += sourceSets.main.get().output + sourceSets["testkit"].output
30+
compileClasspath += sourceSets.main.get().output + sourceSets["testFixtures"].output
31+
runtimeClasspath += sourceSets.main.get().output + sourceSets["testFixtures"].output
5132
}
5233

5334
val acceptanceImplementation by configurations.getting {
@@ -79,7 +60,7 @@ val acceptanceTest = tasks.register<Test>("acceptanceTest") {
7960
testClassesDirs = acceptance.output.classesDirs
8061
classpath = configurations[acceptance.runtimeClasspathConfigurationName] +
8162
sourceSets.main.get().output +
82-
sourceSets["testkit"].output +
63+
sourceSets["testFixtures"].output +
8364
acceptance.output
8465

8566
project.properties["env"]?.let { systemProperty("env.name", it) }
@@ -99,12 +80,11 @@ tasks.check {
9980
dependencies {
10081
implementation(kotlin("reflect"))
10182

102-
testkitImplementation(libs.hamkrest)
103-
testkitImplementation(libs.junit.api)
104-
testkitImplementation(libs.konstruct)
105-
testkitImplementation(libs.faker)
106-
testkitImplementation(libs.minutest)
107-
testkit(sourceSets["testkit"].output)
83+
testFixturesApi(libs.hamkrest)
84+
testFixturesApi(libs.junit.api)
85+
testFixturesApi(libs.konstruct)
86+
testFixturesApi(libs.minutest)
10887

10988
testImplementation(kotlin("test"))
11089
}
90+

domain/src/main/kotlin/security/Encodings.kt

+5-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class HexEncoder(upperCase: Boolean = true) {
77
.let { if (upperCase) it.uppercase(Locale.getDefault()) else it }
88
.toCharArray()
99

10-
fun toHex(bytes: ByteArray): String {
10+
fun encodeToHex(bytes: ByteArray): String {
1111
val hex = CharArray(bytes.size * 2)
1212
for (i in bytes.indices) {
1313
val v = bytes[i].toInt() and 0xFF
@@ -20,13 +20,13 @@ class HexEncoder(upperCase: Boolean = true) {
2020

2121
fun String.toHex(upperCase: Boolean = true) = encodeToByteArray().toHex(upperCase)
2222

23-
fun ByteArray.toHex(upperCase: Boolean = true) = HexEncoder(upperCase).toHex(this)
23+
fun ByteArray.toHex(upperCase: Boolean = true) = HexEncoder(upperCase).encodeToHex(this)
2424

2525

2626
object HexDecoder {
27-
fun fromHex(hex: String): ByteArray = fromHex(hex.toCharArray())
27+
fun decodeFromHex(hex: String): ByteArray = decode(hex.toCharArray())
2828

29-
private fun fromHex(hex: CharArray): ByteArray {
29+
private fun decode(hex: CharArray): ByteArray {
3030
val len = hex.size
3131
require(len and 0x01 == 0) { "odd number of characters" }
3232
val out = ByteArray(len shr 1)
@@ -42,4 +42,4 @@ object HexDecoder {
4242
private fun toDigit(c: Char): Int = Character.digit(c, 16)
4343
}
4444

45-
fun String.fromHex() = HexDecoder.fromHex(this)
45+
fun String.fromHex() = HexDecoder.decodeFromHex(this)

integration/build.gradle.kts

+4-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ dependencies {
1010
implementation(libs.konfig)
1111
runtimeOnly(libs.postgres)
1212

13-
testkitImplementation(project(path = ":domain", configuration = "testkit"))
13+
testImplementation(testFixtures(project(":domain")))
14+
testFixturesImplementation(project(":domain"))
15+
testFixturesImplementation(libs.kabinet)
16+
testFixturesImplementation(libs.konfig)
1417
}
1518

1619
tasks.jar {

server/build.gradle.kts

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
plugins {
23
id("kickstart")
34
application
@@ -9,6 +10,7 @@ application {
910
mainClass.set("kickstart.CLI")
1011
}
1112

13+
1214
dependencies {
1315
implementation(project(":domain"))
1416
implementation(project(":webapp"))
@@ -17,9 +19,9 @@ dependencies {
1719

1820
runtimeOnly(libs.simple)
1921

20-
testkitImplementation(libs.mario)
21-
testkitImplementation(libs.selenium.api)
22-
testkitImplementation(libs.selenium.chromedriver)
22+
testFixturesApi(libs.mario)
23+
testFixturesApi(libs.selenium.api)
24+
testFixturesApi(libs.selenium.chromedriver)
2325

2426
testRuntimeOnly(libs.hamcrest.library)
2527
testRuntimeOnly(libs.juniversalchardet)

server/src/acceptance/kotlin/FeatureTest.kt

+1-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ import kickstart.tasks.signInAs
99
import kickstart.tasks.signOut
1010
import kickstart.tasks.startUsing
1111
import kickstart.tasks.stopUsing
12-
import kotlin.test.AfterTest
13-
import kotlin.test.BeforeTest
14-
import kotlin.test.Test
12+
import kotlin.test.*
1513

1614
class FeatureTest {
1715

File renamed without changes.
File renamed without changes.

webapp/build.gradle.kts

+3-4
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ dependencies {
1111
implementation(libs.konfig)
1212
implementation(libs.molecule)
1313

14-
testkitImplementation(project(path = ":domain", configuration = "testkit"))
15-
testkitImplementation(libs.skrapeit)
16-
testkitImplementation(libs.hamkrest)
17-
14+
testFixturesApi(libs.skrapeit)
15+
testFixturesImplementation(libs.molecule)
16+
testImplementation(testFixtures(project(":domain")))
1817
testImplementation(libs.hamcrest.library)
1918
}
2019

File renamed without changes.

0 commit comments

Comments
 (0)