-
Notifications
You must be signed in to change notification settings - Fork 460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setup unit testing for core/network module [MW-208] #1848
base: development
Are you sure you want to change the base?
Conversation
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 |
There was a problem hiding this comment.
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")
}
}
}
There was a problem hiding this comment.
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
hello hekmatullah,
i was trying to do it but androidTest is giving issues i tried to
understand about kmp project so it is not a necessary to be in kotlin{}
format but it is better right??
…On Fri, Feb 7, 2025 at 2:01 AM Hekmatullah ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In core/network/build.gradle.kts
<#1848 (comment)>
:
> \ No newline at end of file
+ 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
@meetjain6091 <https://github.com/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")
}
}
}
—
Reply to this email directly, view it on GitHub
<#1848 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNJUMJ2G3PGRGYS7CMGEOLL2OPBDLAVCNFSM6AAAAABWUKL4ZWVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDKOJZHAZTSOJTGE>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hey @meetjain6091 , Regarding your question, I’d suggest you go through this article it gives a brief but clear understanding of KMP, and @therajanmaurya sir also mentioned it in Slack. It will help you understand where to put each dependency properly. Also, don’t copy paste all dependencies at once. Instead, add them one by one and understand their purpose. As far as I know, Rajan sir suggested adding a small piece of code and testing it for now. You can start with this in commonTest dependency: implementation(kotlin("test-common")) Then, write a small test like I did (I also shared a pic of it with you). Remember, every dependency should be placed in its specific source set. Hope this helps! Let me know if you run into any issues. |
Thank you ,
I will try to improve it😊
…On Fri, 7 Feb, 2025, 21:40 Hekmatullah, ***@***.***> wrote:
hello hekmatullah, i was trying to do it but androidTest is giving issues
i tried to understand about kmp project so it is not a necessary to be in
kotlin{} format but it is better right??
Hey @meetjain6091 <https://github.com/meetjain6091> ,
Regarding your question, I’d suggest you go through this article
<https://santimattius.github.io/kmp-for-mobile-native-developers-book/#179504e6-f752-80c9-8e3a-c6429f58d137>
it gives a brief but clear understanding of KMP, and @therajanmaurya
<https://github.com/therajanmaurya> sir also mentioned it in Slack. It
will help you understand where to put each dependency properly.
Also, don’t copy paste all dependencies at once. Instead, add them one by
one and understand their purpose. As far as I know, Rajan sir suggested
adding a small piece of code and testing it for now. You can start with
this in commonTest dependency:
implementation(kotlin("test-common"))
Then, write a small test like I did (I also shared a pic of it with you).
Remember, every dependency should be placed in its specific source set.
Hope this helps! Let me know if you run into any issues.
Screenshot.2025-02-07.at.16.05.45.png (view on web)
<https://github.com/user-attachments/assets/e29ae2ec-47b2-45e3-aa13-a1cff4e0c02e>
—
Reply to this email directly, view it on GitHub
<#1848 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BNJUMJZ6O76SPCJNNZN5NAD2OTLIHAVCNFSM6AAAAABWUKL4ZWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNBTGM2TIOBXGU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Issue Fix
Fixes #208
JIRA Task: MW-208
Screenshots
N/A (Unit test setup)
Description
NetworkClientTest.kt
to validate the setup.build.gradle.kts
to include test dependencies.Checklist
AndroidStyle.xml
style template to your code in Android Studio../gradlew check
to make sure you didn't break anything.