Skip to content
6 changes: 6 additions & 0 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:

- run: ./gradlew testDevDebugUnitTest testDebugUnitTest --stacktrace

- run: |
./gradlew \
:core:data:iosSimulatorArm64Test \
:core:model:iosSimulatorArm64Test \
--stacktrace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize for delay. 🙇
There were another module for which iOS tests were not being run, so I specified them.
I am not similar with Gradle syntax, but is this acceptable?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! The iosSimulatorArm64Test might be skipped on ubuntu-latest. Could we change ubuntu-latest to macos-latest?
Additionally, we might need to modify the screenshot-comparison workflow to use macos-latest so that we have the same environment for the screenshots. I think we could merge the existing tests to speed up the process.

      - run: ./gradlew \
            testDevDebugUnitTest \
            testDebugUnitTest \
            :core:data:iosSimulatorArm64Test \
            :core:model:iosSimulatorArm64Test \
            --stacktrace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Yamada-Ika Yamada-Ika Sep 1, 2024 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, CI failed 🙇
I will try to fix


# Saving cost
# - run: ./gradlew koverHtmlReportDevDebug --stacktrace

Expand Down
1 change: 1 addition & 0 deletions core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ kotlin {
commonTest {
dependencies {
implementation(projects.core.model)
implementation(projects.core.testing)
implementation(libs.kotlinTest)
implementation(libs.okIo)
implementation(libs.ktorKotlinxSerialization)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package io.github.droidkaigi.confsched.data.profilecard

import io.github.droidkaigi.confsched.model.ProfileCard
import io.github.droidkaigi.confsched.model.ProfileCardType
import io.github.droidkaigi.confsched.testing.utils.readResourceFile
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import okio.FileSystem
import okio.Path.Companion.toPath
import okio.SYSTEM
import kotlin.test.Test
import kotlin.test.assertEquals
import kotlin.test.assertFails
Expand Down Expand Up @@ -77,18 +76,17 @@ class ProfileCardJsonTest {

@Test
fun `throw exception when both theme and card_type are not exist`() {
val jsonString =
FileSystem.SYSTEM.read("src/commonTest/resources/profilecard/invalid.json".toPath()) {
readUtf8()
}
val jsonString = readResourceFile("profilecard/invalid.json".toPath()) {
readUtf8()
}

assertFails {
Json.decodeFromString<ProfileCardJson>(jsonString).toModel()
}
}

private fun readJsonString(version: Int): String {
return FileSystem.SYSTEM.read("src/commonTest/resources/profilecard/v$version.json".toPath()) {
return readResourceFile("profilecard/v$version.json".toPath()) {
readUtf8()
}
}
Expand All @@ -102,10 +100,9 @@ class ProfileCardJsonTest {
}

private fun assertSerializedJson(actual: String) {
val expected =
FileSystem.SYSTEM.read("src/commonTest/resources/profilecard/v2.json".toPath()) {
readUtf8()
}
val expected = readResourceFile("profilecard/v2.json".toPath()) {
readUtf8()
}

assertEquals(expected.trim(), actual.trim())
}
Expand Down
85 changes: 52 additions & 33 deletions core/testing/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,40 +1,59 @@
plugins {
id("droidkaigi.primitive.android")
id("droidkaigi.primitive.android.kotlin")
id("droidkaigi.primitive.android.compose")
id("droidkaigi.primitive.android.hilt")
id("droidkaigi.primitive.kmp")
id("droidkaigi.primitive.kmp.android")
id("droidkaigi.primitive.kmp.android.hilt")
id("droidkaigi.primitive.kmp.compose")
id("droidkaigi.primitive.kmp.ios")
id("droidkaigi.primitive.detekt")
}

android.namespace = "io.github.droidkaigi.confsched.core.testing"

dependencies {
implementation(projects.core.model)
implementation(projects.core.designsystem)
implementation(projects.core.data)
implementation(projects.core.droidkaigiui)
implementation(projects.feature.main)
implementation(projects.feature.sessions)
implementation(projects.feature.profilecard)
implementation(projects.feature.about)
implementation(projects.feature.staff)
implementation(projects.feature.sponsors)
implementation(projects.feature.settings)
implementation(projects.feature.favorites)
implementation(projects.feature.eventmap)
implementation(projects.feature.contributors)
implementation(libs.daggerHiltAndroidTesting)
implementation(libs.roborazzi)
implementation(libs.kermit)
implementation(libs.coilTest)
api(projects.core.testingManifest)
api(libs.composeNavigation)
api(libs.roborazziRule)
api(libs.roborazziCompose)
api(libs.robolectric)
api(libs.composeUiTestJunit4)
implementation(libs.composeMaterialWindowSize)
implementation(libs.composablePreviewScanner)
implementation(libs.composablePreviewScannerJvm)
implementation(libs.roborazziPreviewScannerSupport)
kotlin {
sourceSets {
androidMain {
dependencies {
implementation(projects.core.model)
implementation(projects.core.designsystem)
implementation(projects.core.data)
implementation(projects.core.droidkaigiui)
implementation(projects.feature.main)
implementation(projects.feature.sessions)
implementation(projects.feature.profilecard)
implementation(projects.feature.about)
implementation(projects.feature.staff)
implementation(projects.feature.sponsors)
implementation(projects.feature.settings)
implementation(projects.feature.favorites)
implementation(projects.feature.eventmap)
implementation(projects.feature.contributors)
implementation(libs.daggerHiltAndroidTesting)
implementation(libs.roborazzi)
implementation(libs.kermit)
implementation(libs.coilTest)
api(projects.core.testingManifest)
api(libs.composeNavigation)
api(libs.roborazziRule)
api(libs.roborazziCompose)
api(libs.robolectric)
api(libs.composeUiTestJunit4)
implementation(libs.composeMaterialWindowSize)
implementation(libs.composablePreviewScanner)
implementation(libs.composablePreviewScannerJvm)
implementation(libs.roborazziPreviewScannerSupport)
}
}

commonMain {
dependencies {
implementation(libs.okIo)
}
}

iosMain {
dependencies {
implementation(libs.okIo)
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package io.github.droidkaigi.confsched.testing.utils

expect inline fun <T> readResourceFile(filePath: okio.Path, block: okio.BufferedSource.() -> T): T
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package io.github.droidkaigi.confsched.testing.utils

import okio.BufferedSource
import okio.FileSystem
import okio.Path
import okio.Path.Companion.toPath
import platform.Foundation.NSBundle

actual inline fun <T> readResourceFile(filePath: Path, block: BufferedSource.() -> T): T {
return FileSystem.SYSTEM.read(
NSBundle.mainBundle.bundlePath.toPath().parent!!.parent!!.parent!!.parent!!
.div("src").div("commonTest").div("resources").div(filePath),
) {
block()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package io.github.droidkaigi.confsched.testing.utils

import okio.FileSystem
import okio.Path.Companion.toPath

actual inline fun <T> readResourceFile(filePath: okio.Path, block: okio.BufferedSource.() -> T): T {
return FileSystem.SYSTEM.read(
"src".toPath().div("commonTest").div("resources").div(filePath),
) {
block()
}
}