#1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ
#1-1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ์ข ๋ฅ
๋จผ์ , ์ฌ๊ธฐ์ ์๋ ๊ตฌ๊ธ ๊ณต์ ๋ฌธ์์์ ์๋๋ก์ด๋ ์ฑ ํ
์คํธ์ ๋ํ ๊ฐ์๋ฅผ ์ฝ์ผ๋ฉด ์ข๋ค. ํด๋น ๊ตฌ๊ธ ๊ณต์ ๋ฌธ์์์ ๋ณต์ฌํด์จ ์์ ๊ทธ๋ฆผ์ ํ
์คํธ๋ฅผ ์ด 3๋จ๊ณ๋ก ๋๋๊ณ ์๋ค. ๋จผ์ Unit test๋ ํจ์๋ ํด๋์ค ๋ฑ์ ์ฑ์ ์์ฃผ ์์ ๋ถ๋ถ์ ๊ฒ์ฆํ๋ ํ
์คํธ๊ณ , ๋ณธ ๊ฒ์๊ธ์์ ๋ค๋ฃฐ ๋ด์ฉ์ด๋ค. ๋๋ฒ์งธ๋ Integration(ํตํฉ) test๋ก, ๋ฐ์ดํฐ๋ฒ ์ด์ค ์ฐ๋, API ํธ์ถ ๋ฑ ๋ชจ๋ ๊ฐ์ ์ํธ์์ฉ์ ๊ฒ์ฆํ๋ค. ๋ง์ง๋ง์ End-to-end(๋๊ณผ ๋์ ๋ถ์ด๋) test๋ค. ์ ์ฒด ์์คํ
์ ๋ชจ๋ ๊ตฌ์ฑ ์์(๋) ๊ฐ์ ์ํธ์์ฉ(์ ๋ถ๋ ์ง)์ ํ์ธํ๋ค. End-to-end test์์์ '๊ตฌ์ฑ ์์'๋ ์ฌ์ฉ์์ ์
๋ ฅ์ด๋ ์๋๋ฆฌ์ค ๋ฑ๊น์ง ํฌํจํ๋ค. Integration test์ ์ด๋ฆ์ ๋ฌ์์ค๋ ๋น์ทํ์ง๋ง, ์์ฃผ ๋์ ๋ฒ์๋ฅผ ํ
์คํธํ๋ค.
#1-2 ์๋๋ก์ด๋ ์๋ฎฌ๋ ์ดํฐ์ Unit Testing
์๋๋ก์ด๋ ์
๋ฌธ์ ์
์ฅ์์, ์๋๋ก์ด๋ ํ๋ก์ ํธ์์์ ํ
์คํธ๋ ๊ธฐ๋ณธ์ ์ผ๋ก Android Virtual Device๋ฅผ ํตํ ํ์ธ์ด๋ค. ์ด๋ #1-1์ ๊ทธ๋ฆผ์์ End-to-End test์ ํ ์ข
๋ฅ๋ผ๊ณ ๋ณผ ์ ์๋ค. ํ์ง๋ง ์ด๋ ์ฌ์ฉ์ ๊ฒฝํ ์์ฃผ์ ํ์ธ์ธ๋ฐ๋ค๊ฐ, ํ์์๋ ๋ถ๋ถ๊น์ง ํฌํจํด ํ
์คํธํ๊ฒ ๋๋ค. ์ฆ, ์ฑ์ ํต์งธ๋ก ํ
์คํธํ๋ ์ด์ฐ๋ณด๋ฉด ์ฝ๊ฐ ๋ฌด์ํ ๋ฐฉ๋ฒ์ด๋ค. ์ด๋ ์๋๋ก์ด๋์์ ๋ ๋ค๋ฅธ ํ
์คํธ ๋ฐฉ๋ฒ์ ์ ๊ณตํ๋๋ฐ, ์ด ๋ฐฉ๋ฒ๋ค์ ํ๋ก์ ํธ๋ฅผ ๋ถ๋ถ(Unit)์ ์ผ๋ก ํ
์คํธํ๊ฒ ๋ง๋ค์ด์ค๋ค.
#2 ์๋๋ก์ด๋ Unit Testing์ ์ข ๋ฅ
#2-1 Local unit test
๋ก์ปฌ ๋จ์ ํ ์คํธ ๋น๋ | Android Developers
์ด ํ์ด์ง๋ Cloud Translation API๋ฅผ ํตํด ๋ฒ์ญ๋์์ต๋๋ค. ๋ก์ปฌ ๋จ์ ํ ์คํธ ๋น๋ ์ปฌ๋ ์ ์ ์ฌ์ฉํด ์ ๋ฆฌํ๊ธฐ ๋ด ํ๊ฒฝ์ค์ ์ ๊ธฐ์ค์ผ๋ก ์ฝํ ์ธ ๋ฅผ ์ ์ฅํ๊ณ ๋ถ๋ฅํ์ธ์. ๋ก์ปฌ ํ ์คํธ๋ Android ๊ธฐ๊ธฐ๋ ์
developer.android.com
JVM(Java Virtual Machine)์ ์ฌ์ฉํ์ฌ ๋น ๋ฅธ ํ
์คํธ๋ฅผ ์คํํ๋ค. ์ฆ, Android ์๋ฎฌ๋ ์ดํฐ์๋ ๊ด๋ จ์ด ์๋ค. ๊ทธ๋ ๋ค๊ณ Android ํ๋ ์์ํฌ์ ๊ด๋ จ๋ ํ
์คํธ๋ฅผ ํ ์ ์๋ค๋ ๋ง์ ์๋๋ค. Context์ ๊ฐ์ด Android์ ์ค์ ๋ฐํ์ ํ๊ฒฝ๊ณผ ๊ด๋ จ๋ ๊ฐ๋
์ ๋ํ ํ
์คํธ ๋ฑ์ ์งํํ์ง ๋ชปํ์ง๋ง, ViewModel๊ณผ ๊ฐ์ด UI ๋ฐ ์๋๋ก์ด๋ ํ๋ ์์ํฌ์์ ์์กด์ฑ์ด ์ ์ ๊ฐ์ฒด๋ ํ
์คํธ๊ฐ ๊ฐ๋ฅํ๋ค. ์๋ํ๋ฉด ํ์ํ ๊ฒฝ์ฐ Dependency๋ฅผ Test double๋ก ๋ฌ๋ฒ๋ฆฌ๋ฉด ๊ทธ๋ง์ด๊ธฐ ๋๋ฌธ์ด๋ค. ๊ฒ๋ค๊ฐ, Robolectric๋ Mockito์ ๊ฐ์ Unit Test์ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ Android ํ๋ ์์ํฌ์ ์ผ๋ถ๋ฅผ ๋ชจ๋ฐฉํ๊ฑฐ๋ ์ํธ์์ฉ๋ฅผ ๊ฐ๋ฅ์ผ ๋ง๋ค์ด์ฃผ์ด Local unit test์ ํ๊ณ๋ฅผ ๊ฝค๋ ์ค์ฌ์ค๋ค. ๊ทธ๋ฌ๋ ์ด๋ ๊ฒํด๋ ํ
์คํธํ ์ ์๋ ์ํฉ์ด๋ผ๋ฉด ์๋์ ์๋ Instrumented test๋ก ํ
์คํธํ๋ค. Local unit test ์ํ์ ์ํด ์กด์ฌํ๋ "ํ๋ก์ ํธ๋ช
/๋ชจ๋๋ช
/src/test/java"๋ผ๋ ์ ์ฉ ๋๋ ํ ๋ฆฌ๊ฐ ์๋๋ก์ด๋ ํ๋ก์ ํธ์ ์๋ค.
#2-2 Instrumented test
๊ณ์ธก ํ ์คํธ ๋น๋ | Android Developers
์ด ํ์ด์ง๋ Cloud Translation API๋ฅผ ํตํด ๋ฒ์ญ๋์์ต๋๋ค. ๊ณ์ธก ํ ์คํธ ๋น๋ ์ปฌ๋ ์ ์ ์ฌ์ฉํด ์ ๋ฆฌํ๊ธฐ ๋ด ํ๊ฒฝ์ค์ ์ ๊ธฐ์ค์ผ๋ก ์ฝํ ์ธ ๋ฅผ ์ ์ฅํ๊ณ ๋ถ๋ฅํ์ธ์. ๊ณ์ธก ํ ์คํธ๋ ์ค์ ๊ธฐ๊ธฐ ๋๋ ์๋ฎฌ
developer.android.com
#2-1 ๋ฌ๋ฆฌ, Android ๊ธฐ๊ธฐ์์ ์คํ๋๋ค. ๋ฐ๋ผ์ Android ํ๋ ์์ํฌ API๋ฅผ ์ง์ ํ์ฉํ ์ ์๋ค. ๋ฐ๋ผ์ Local unit test์ ๋นํด ๋ ๋์ ์ ๋ขฐ์ฑ & ์ถฉ์ค๋๋ฅผ ์ง๋๋ค. ํ์ง๋ง ํจ์ฌ ๋๋ฆฌ๋ฏ๋ก Local unit test๊ฐ ๋ถ๊ฐ๋ฅํ ๋์ ์ ํ์ง๋ก ๋๋ ๊ฒ์ด ์ข๋ค. Instrumented test๋ฅผ ์ํด ์กด์ฌํ๋ Instrumentation๋ผ๋ ํด๋์ค๊ฐ ์๋ค. ์ด๋ฅผ ํตํด ์ ํ๋ฆฌ์ผ์ด์
์ ๋ชจ๋ํฐ๋งํ๋ฉด์ Activity, Service, BroadcastReceiver ๋ฑ์ ์คํํ๊ฑฐ๋, ๊ธฐ๊ธฐ์ ๋ฒํผ ํด๋ฆญ์ด๋ ์คํฌ๋ฆฐ ํฐ์น ๋ฑ์ ์ฌ์ฉ์ ์
๋ ฅ ๋ํ ์๋ฎฌ๋ ์ด์
๊ฐ๋ฅํ๋ค. Instrumented test ์ํ์ ์ํด ์กด์ฌํ๋ "ํ๋ก์ ํธ๋ช
/๋ชจ๋๋ช
/src/androidTest/java"๋ผ๋ ์ ์ฉ ๋๋ ํ ๋ฆฌ๊ฐ ์๋๋ก์ด๋ ํ๋ก์ ํธ์ ์๋ค.
#3 Unit test๋ฅผ ์ํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ค์ด๋ก๋
#3-1 dependency์ ์ข ๋ฅ
plugins {
...
}
android {
...
}
dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.2.1")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1")
}
์๋๋ก์ด๋ ์คํ๋์ค์์ [File] - [New] - [New Project] - [Empty Views Activity]ํ ๋, ๋ชจ๋ ์์ค build.gradle.kts์ ๊ธฐ๋ณธ์ ์ผ๋ก ๋ค์ด๊ฐ์๋ dependency๋ค. ํฐ ๋ฐ์ดํ(") ์ฌ์ด์ ์๋ ์ข
์์ฑ์ ๋ฌธ์์ด ์๋ณ์ ๊ทธ๋ฆฌ๊ณ ๊ทธ ์ข
์์ฑ์ ๊ตฌํ ๋ฐฉ๋ฒ์ ์ ์ํ๋ค. ๊ทธ๋ฐ๋ฐ, ์ข
์์ฑ์ ๊ตฌํ ๋ฐฉ๋ฒ์ด ํ๋๊ฐ ์๋ ๋ชจ์ต์ ๋ณผ ์ ์๋ค. ์ฌ๊ธฐ์๋ implementation, testImplementation, androidTestImplementation์ 3๊ฐ์ง๋ก ๋ฒ์ฃผ๊ฐ ๋๋์ด์ ธ ์๋ค.
implementation์ ํ๋ก์ ํธ์ ๋ชจ๋ ๊ณณ์์ ์ข
์์ฑ(Dependency)์ ์ ๊ณตํ๋ค. testImplementation์ Local unit test์๊ฒ๋ง ์ข
์์ฑ์ ์ ๊ณตํ๋ค. ์ด ๋ง์, ํ๋ก์ ํธ๋ช
/๋ชจ๋๋ช
/src/test/java์ ๋๋ ํ ๋ฆฌ์์๋ง ํตํ๋ ์ข
์์ฑ์ด๋ผ๋ ์ด์ผ๊ธฐ๋ค. ํ๋ก์ ํธ๋ฅผ APK๋ก ๋ง๋ค์ด Play Store์ ์ฌ๋ฆด ๋ ์ด testImplementation์ (APK์ ์ฉ๋ ๋ญ๋น๋ฅผ ๋ง๊ธฐ ์ํด) ํฌํจ๋์ง ์๋๋ค. androidTestImplementation์ Instrumented test์๊ฒ๋ง ์ข
์์ฑ์ ์ ๊ณตํ๋ค. ์ด ๋ง์, ํ๋ก์ ํธ๋ช
/๋ชจ๋๋ช
/src/androidTest/java์ ๋๋ ํ ๋ฆฌ์์๋ง ํตํ๋ ์ข
์์ฑ์ด๋ผ๋ ์ด์ผ๊ธฐ๋ค. ํ๋ก์ ํธ๋ฅผ APK๋ก ๋ง๋ค์ด Play Store์ ์ฌ๋ฆด ๋ ์ด androidTestImplementation์ (APK์ ์ฉ๋ ๋ญ๋น๋ฅผ ๋ง๊ธฐ ์ํด) ํฌํจ๋์ง ์๋๋ค.
#3-2 Gradle ๋ฒ์ ๋ฐ AGP ๋ฒ์ ์ค์
[File] - [Project Structure...]์์ ํ๋ก์ ํธ์ Gradle ๋ฒ์ ๋ฐ AGP(Android Gradle Plugin) ๋ฒ์ ์ ๊ฐ๊ฐ 8.0 ๋ฐ 8.1.2๋ก ์ ํํ๋ค.
#3-3 ํ๋ก์ ํธ ์์ค build.gradle ์ค๋น
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.2" apply false
id("org.jetbrains.kotlin.android") version "1.9.0" apply false
// KSP (Annotation ์ฝ๊ธฐ)
id("com.google.devtools.ksp") version "1.9.0-1.0.13" apply false
}
#3-4 ๋ชจ๋ ์์ค build.gradle ์ค๋น
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
// kapt, KSP (Annotation ์ฝ๊ธฐ)
id("kotlin-kapt")
id("com.google.devtools.ksp")
}
android {
namespace = "com.example.setupenvironment"
compileSdk = 34
defaultConfig {
applicationId = "com.example.setupenvironment"
minSdk = 26
targetSdk = 33
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
buildFeatures {
buildConfig = true // BuildConfig ํด๋์ค๊ฐ ํ์ํ ์
dataBinding = true // ๋ฐ์ดํฐ ๋ฐ์ธ๋ฉ ์
}
}
dependencies {
// ํ๋ก์ ํธ ์์ฑ ์ built-in ๋์ด์๋ Dependency๋ค (๋ฒ์ฃผํ๋ฅผ ์ํด, ์ด ์ค ์ผ๋ถ๋ ์๋์ชฝ ์ฝ๋๋ก ์ฎ๊ฒผ์)
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.appcompat:appcompat:1.7.0")
implementation("com.google.android.material:material:1.12.0")
implementation("androidx.constraintlayout:constraintlayout:2.1.4")
androidTestImplementation("androidx.test.espresso:espresso-core:3.6.1") // Android์ฉ์ผ๋ก ํน๋ณํ ๋ง๋ค์ด์ง ์ฌ์ฉ์ ์ธํฐํ์ด์ค ํ
์คํธ ํ๋ ์์ํฌ
// JUnit: ์๋ฐ์ ์๋๋ก์ด๋ ๊ฐ๋ฐ์์ ํ์ค์ผ๋ก ์ฌ์ฉ๋๋ ํ
์คํธ ํ๋ ์์ํฌ. ๋ค๋ฅธ Dependency๋ค์ ๊ธฐ๋ฐ์ผ๋ก๋ ๋๋ฆฌ ์ฐ์ธ๋ค
testImplementation("junit:junit:4.13.2") // ํ๋ก์ ํธ ์์ฑ ์ built-in ๋์ด์๋ Dependency.
androidTestImplementation("androidx.test.ext:junit:1.2.1") // ํ๋ก์ ํธ ์์ฑ ์ built-in ๋์ด์๋ Dependency. JUnit์ ํ์ฅํด ์๋๋ก์ด๋์์ ํ
์คํธํ ์ ์๊ฒ ํด์ค
testImplementation("androidx.test.ext:junit:1.2.1") // JUnit์ ํ์ฅํด ์๋๋ก์ด๋์์ ํ
์คํธํ ์ ์๊ฒ ํด์ค (Local unit test์ฉ)
// Lifecycle
val lifecycleVersion = "2.8.3"
testImplementation("androidx.lifecycle:lifecycle-runtime-testing:$lifecycleVersion") // Test์ฉ LifecycleOwner ๋ฑ ์ ๊ณต
// LiveData
val archVersion = "2.2.0"
implementation("androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion")
testImplementation("androidx.arch.core:core-testing:$archVersion") // Test helpers for LiveData (ํ
์คํธ์ LiveData๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ)
androidTestImplementation("androidx.arch.core:core-testing:$archVersion") // Test helpers for LiveData (ํ
์คํธ์ LiveData๋ฅผ ์ฌ์ฉํ๋ ๊ฒฝ์ฐ) (Instrumented test์ฉ)
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:$lifecycleVersion") // ViewModel์ ์ํ ๊ด๋ฆฌ๋ฅผ ๋๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
// Coroutines
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4")
// Dagger
val daggerVersion = "2.51.1"
implementation("com.google.dagger:dagger:$daggerVersion")
kapt("com.google.dagger:dagger-compiler:$daggerVersion") // Dagger์ Annotation ๊ตฌ๋ฌธ์ ์ฝ๊ธฐ ์ํ ์ข
์์ฑ
// Retrofit
val retrofitVersion = "2.11.0"
val okhttp3Version = "4.12.0"
implementation("com.squareup.retrofit2:retrofit:$retrofitVersion")
implementation("com.squareup.retrofit2:converter-gson:$retrofitVersion") // JSON ์ปจ๋ฒํฐ
implementation("com.squareup.okhttp3:logging-interceptor:$okhttp3Version") // ์น ํต์ ๋ก๊ทธ
testImplementation("com.squareup.okhttp3:mockwebserver:$okhttp3Version") // ์น ์๋ฒ Mock ์์ฑ
// Room
val roomVersion = "2.6.1"
implementation("androidx.room:room-runtime:$roomVersion")
kapt("androidx.room:room-compiler:$roomVersion") // Room์ Annotation ๊ตฌ๋ฌธ์ ์ฝ๊ธฐ ์ํ ์ข
์์ฑ
implementation("androidx.room:room-ktx:$roomVersion") // Room์์ ์ฌ์ฉํ ์ ์๋ Coroutines ํด๋์ค ๋ผ์ด๋ธ๋ฌ๋ฆฌ
// Truth: ํ
์คํธ ์ฑ๊ณต ๋ฐ ์คํจ ๋ฉ์์ง๋ฅผ ๋ ์ฝ๊ธฐ ์ฝ๊ฒ ๋ง๋ค์ด์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
val truthVersion = "1.4.3"
testImplementation("com.google.truth:truth:$truthVersion")
testImplementation("com.google.truth.extensions:truth-java8-extension:$truthVersion") // Truth๊ฐ Java 8์ ๋์
๋ ๊ธฐ๋ฅ์ ์ด์ฉํด ํ
์คํธํ๋๋ก ๋ง๋ค์ด์ฃผ๋ ์ถ๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
androidTestImplementation("com.google.truth:truth:$truthVersion")
androidTestImplementation("com.google.truth.extensions:truth-java8-extension:$truthVersion") // Truth๊ฐ Java 8์ ๋์
๋ ๊ธฐ๋ฅ์ ์ด์ฉํด ํ
์คํธํ๋๋ก ๋ง๋ค์ด์ฃผ๋ ์ถ๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ (Instrumented test์ฉ)
// (JUnit์ ๊ธฐ๋ฐ) Mockito: Test double์ ์ผ์ข
์ธ Mock ์์ฑ์ ๋์์ฃผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
testImplementation("org.mockito:mockito-core:5.12.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.3.1") // ์ข ๋ 'Kotlin์ค๋ฌ์ด' ๋ฐฉ์์ผ๋ก Mock ๊ฐ์ฒด๋ฅผ ์์ฑํ๊ณ ์ฌ์ฉํ ์ ์๊ฒ ๋์์ฃผ๋ ์ถ๊ฐ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
// (JUnit์ ๊ธฐ๋ฐ) Robolectric: ์๋๋ก์ด๋ ์๋ฎฌ๋ ์ดํฐ๋ฅผ ๋ชจ๋ฐฉํด ๋น ๋ฅด๊ฒ ์๋๋ก์ด๋ ํ๊ฒฝ์ ์๋ฎฌ๋ ์ด์
. ์ฆ, ์๋๋ผ๋ฉด Instrumented test๋ฅผ ์งํํด์ผ๋๋ ๊ฑธ Local unit test๋ก ์งํํ๊ฒ ๋ง๋ค์ด์ค
testImplementation("org.robolectric:robolectric:4.12.2")
// (JUnit์ ๊ธฐ๋ฐ) Glide: ์ด๋ฏธ์ง ๋ถ๋ฌ์ค๊ธฐ ๋ฐ ๊ด๋ฆฌ
implementation("com.github.bumptech.glide:glide:4.16.0")
}
#5์ ์๋ ์ด์ด์ง๋ ๊ธ๋ค์์ ์ฌ์ฉํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋ฐ ํ
์คํธ์ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ค์ ์ ๋ถ ํฌํจํ๋ค. testImplementation( ... )์ ๋นํด androidTestImplementation( ... )์ ๊ฐฏ์๊ฐ ์ ์ ๊ฒ์ androidTestImplementation( ... )์ ํน์ฑ์ ๊ธฐ์ธํ๋ค. ๋ฐ๋ก, ํ
์คํธ ์์ ์๋๋ก์ด๋ ํ๋ ์์ํฌ๋ฅผ ์ฌ์ฉํ๋ค๋ ์ ๋ง์ด๋ค. ๋๋ถ์ ํ๋ก์ ํธ ์ ์ญ์ Dependency๋ฅผ ์ ๊ณตํ๋ implementation( ... )๋ง์ผ๋ก ์ข
์์ฑ์ด ์ถฉ์กฑ๋ ๊ฒ์ด๋ค. ๋, compileOptions ๋ฐ kotlinOptions์ JDK ๋ฒ์ ์ด 17์์ ์ ์ํ์.
๋ผ์ด๋ธ๋ฌ๋ฆฌ ๋งํฌ ๋ชจ์
JUnit4
JUnit – About
JUnit is a simple framework to write repeatable tests. It is an instance of the xUnit architecture for unit testing frameworks. @Test public void newArrayListsHaveNoElements() { assertThat(new ArrayList ().size(), is(0)); } @Test public void sizeReturnsNum
junit.org
Truth
Truth - Fluent assertions for Java and Android
What is Truth? Truth is a library for performing assertions in tests: assertThat(notificationText).contains("testuser@google.com"); Truth is owned and maintained by the Guava team. It is used in the majority of the tests in Google’s own codebase. Why use
truth.dev
Mockito
Mockito framework site
Intro Why How More Who Links Training Why drink it? Mockito is a mocking framework that tastes really good. It lets you write beautiful tests with a clean & simple API. Mockito doesn’t give you hangover because the tests are very readable and they produc
site.mockito.org
Robolectric
Robolectric
test-drive your Android code Running tests on an Android emulator or device is slow! Building, deploying, and launching the app often takes a minute or more. That's no way to do TDD. There must be a better way. Robolectric is a framework that brings fast a
robolectric.org
Glide
Glide v4 : Fast and efficient image loading for Android
About Glide Glide is a fast and efficient image loading library for Android focused on smooth scrolling. Glide offers an easy to use API, a performant and extensible resource decoding pipeline and automatic resource pooling. Glide supports fetching, decodi
bumptech.github.io
#3-5 Gradle์ด ์ฌ์ฉํ JDK ๋ฒ์ ์ง์
[File] - [Setting...] - [Build, Execution, Deployment] - [Build Tools] - [Gradle]์์ Gradle์ด ์ฌ์ฉํ JDK๋ฅผ ์ง์ ํ๋ค. General settings์์๋ JDK 17์ ๋๋ ํ ๋ฆฌ๋ฅผ ์ง์ ํ๋ค. Gradle projects์์๋ Gradle JDK๋ฅผ ์ค์ ํ๋ค. ์ด ๋ ์ด ๊ฒ์๊ธ์ ์ฐธ์กฐํด JDK 17 ์ค์น ๋ฐ ํ๊ฒฝ ๋ณ์ JAVA_HOME์ ์ค์ ํ๊ณ JAVA_HOME์ ์ ํํ๊ฑฐ๋, ์ด๋ฏธ ์ค์น๋ 17๋ฒ์ ์ JDK ๋๋ ํ ๋ฆฌ๋ฅผ ์ ํํ๋ค. ํ์์ ๋ฐฉ๋ฒ์ด ๋ ๊ฐํธํ๋ค. ๋ง์ฝ ๋ชฉ๋ก์ '์ด๋ฏธ ์ค์น๋ 17๋ฒ์ ์ JDK ๋๋ ํ ๋ฆฌ'๊ฐ ๋ณด์ด์ง ์๋๋ค๋ฉด, [Download JDK...]๋ฅผ ๋๋ฌ ๋ค์ด๋ก๋ํ๋ฉด ๋๋ค.
#4 ์์ฝ
Unit Test๋ฅผ ํตํด AVD๋ก ์ผ์ผํ ํ์ธํ๋ ์๊ฐ ๋ญ๋น๋ฅผ ์ค์ธ๋ค.
#5 ์ด์ด์ง๋ ๊ธ
#5-1 Android unit test์ ๊ธฐ์ด
[Android] Unit Testing - ๊ธฐ์ด
#1 ์ด์ ๊ธ#1-1 Unit Testing ๊ฐ์ [Android] Unit Testing - ๊ฐ์์ ํ๊ฒฝ ์ค์ #1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ#1-1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ์ข ๋ฅ๋จผ์ , ์ฌ๊ธฐ์ ์๋ ๊ตฌ๊ธ ๊ณต์ ๋ฌธ์์์ ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ๋ํ
kenel.tistory.com
#5-2 ViewModel ํ ์คํธ
[Android] Unit Testing - ViewModel
#1 ์ด์ ๊ธ#1-1 Unit Testing ๊ฐ์ [Android] Unit Testing - ๊ฐ์์ ํ๊ฒฝ ์ค์ #1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ#1-1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ์ข ๋ฅ๋จผ์ , ์ฌ๊ธฐ์ ์๋ ๊ตฌ๊ธ ๊ณต์ ๋ฌธ์์์ ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ๋ํ
kenel.tistory.com
#5-3 Room, LiveData ํ ์คํธ
[Android] Unit Testing - Room๊ณผ LiveData
#1 ์ด์ ๊ธ#1-1 Unit Testing ๊ฐ์ [Android] Unit Testing - ๊ฐ์์ ํ๊ฒฝ ์ค์ #1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ#1-1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ์ข ๋ฅ๋จผ์ , ์ฌ๊ธฐ์ ์๋ ๊ตฌ๊ธ ๊ณต์ ๋ฌธ์์์ ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ๋ํ
kenel.tistory.com
#5-4 Retrofit ํ ์คํธ
[Android] Unit Testing - Retrofit
#1 ์ด์ ๊ธ#1-1 Unit Testing ๊ฐ์ [Android] Unit Testing - ๊ฐ์์ ํ๊ฒฝ ์ค์ #1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ#1-1 ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ์ข ๋ฅ๋จผ์ , ์ฌ๊ธฐ์ ์๋ ๊ตฌ๊ธ ๊ณต์ ๋ฌธ์์์ ์๋๋ก์ด๋ ์ฑ ํ ์คํธ์ ๋ํ
kenel.tistory.com
'๊นจ์ ๊ฐ๋ ๐ > Android' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[Android] Unit Testing - ViewModel (0) | 2024.07.08 |
---|---|
[Android] Unit Testing - ๊ธฐ์ด (0) | 2024.07.08 |
[Android] Dagger2 - Application ํ์ฉํ๊ธฐ (0) | 2024.06.25 |
[Android] Dagger2 - Activity์ Dependency ์ฃผ์ (0) | 2024.06.25 |
[Android] Dagger2 - ์ธํฐํ์ด์ค ๊ตฌํ์ฒด ์ฃผ์ (@Binds) (0) | 2024.06.25 |