Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion core/network/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,9 @@ dependencies {
add("kspIosX64", libs.ktorfit.ksp)
add("kspIosArm64", libs.ktorfit.ksp)
add("kspIosSimulatorArm64", libs.ktorfit.ksp)
}
testImplementation ("org.jetbrains.kotlin:kotlin-test:1.8.21")
testImplementation ("org.jetbrains.kotlin:kotlin-test-junit:1.8.21")
testImplementation ("io.mockk:mockk:1.13.4") // Mocking library
testImplementation ("androidx.test.ext:junit:1.1.5") // JUnit for Android
testImplementation ("androidx.test:core:1.4.0") // For Android testing support
Copy link
Copy Markdown
Member

@HekmatullahAmin HekmatullahAmin Feb 6, 2025

Choose a reason for hiding this comment

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

@meetjain6091 I noticed that the test dependencies are currently in the dependencies {} block, but since this is a Kotlin Multiplatform (KMP) project, it would be better to place them inside the kotlin {} block under commonTest and androidTest.

like this:

kotlin {

sourceSets {
    commonTest.dependencies {
        implementation("org.jetbrains.kotlin:kotlin-test:1.8.21")
        implementation("io.mockk:mockk:1.13.4")  // Mocking library
    }

    androidTest.dependencies {
        implementation("androidx.test.ext:junit:1.1.5")
        implementation("androidx.test:core:1.4.0")
    }
}

}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Okay will surely update it

}
36 changes: 36 additions & 0 deletions core/network/src/test/kotlin/com/example/NetworkClientTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import io.mockk.every
import io.mockk.mockk
import io.mockk.verify
import kotlinx.coroutines.runBlocking
import org.junit.Assert.assertEquals
import org.junit.Test

// Example class (Replace this with the actual NetworkClient class you're testing)
class NetworkClient {
fun fetchData(url: String): String {
// Normally, this would make a network request
return "Real Response"
}
}

// Unit Test for NetworkClient
class NetworkClientTest {

@Test
fun `test fetchData returns expected response`() = runBlocking {
// Arrange: Create a mock of NetworkClient
val mockClient = mockk<NetworkClient>()

// Mock behavior
every { mockClient.fetchData("https://example.com") } returns "Mocked Response"

// Act: Call the method
val response = mockClient.fetchData("https://example.com")

// Assert: Verify the response
assertEquals("Mocked Response", response)

// Verify that fetchData was called once
verify(exactly = 1) { mockClient.fetchData("https://example.com") }
}
}
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ jbSavedState = "1.2.2"
packageName = "MifosWallet"
packageNamespace = "org.mifospay.desktop"
packageVersion = "1.0.0"
lifecycleRuntimeKtx = "2.8.7"

[libraries]
accompanist-pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "accompanist" }
Expand Down Expand Up @@ -312,6 +313,8 @@ moko-permission = { group = "dev.icerock.moko", name = "permissions", version.re
moko-permission-compose = { group = "dev.icerock.moko", name = "permissions-compose", version.ref = "mokoPermission" }

window-size = { group = "dev.chrisbanes.material3", name = "material3-window-size-class-multiplatform", version.ref = "windowsSizeClass" }
androidx-lifecycle-runtime-ktx = { group = "androidx.lifecycle", name = "lifecycle-runtime-ktx", version.ref = "lifecycleRuntimeKtx" }
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.

why did you add these?

androidx-ui-graphics = { group = "androidx.compose.ui", name = "ui-graphics" }

[bundles]
androidx-compose-ui-test = [
Expand Down
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -76,3 +76,4 @@ include(":feature:upi-setup")
include(":feature:qr")

include(":libs:mifos-passcode")
include(":core:network:networkclienttest")