diff --git a/README.md b/README.md index fe78b7c..126cfd2 100644 --- a/README.md +++ b/README.md @@ -11,4 +11,7 @@ ## 🎲 2단계 1. loadGithubProfile 메소드 호출 성공 시 GithubProfile을 가져온다. -2. loadGithubProfile 메소드 호출 실패 시 isError의 value 가 True가 된다. \ No newline at end of file +2. loadGithubProfile 메소드 호출 실패 시 isError의 value 가 True가 된다. + +## 🎲 3단계 +1. 올바른 패키지 명을 반환한다. \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 7fe4e7e..9ecf161 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -69,6 +69,8 @@ dependencies { testImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.6.4' testImplementation 'com.google.truth:truth:1.1.3' testImplementation 'io.mockk:mockk:1.13.2' + // okhttp mock web server + testImplementation 'com.squareup.okhttp3:mockwebserver:4.9.1' // Instrumentation test androidTestImplementation "androidx.test:runner:1.5.2" @@ -79,4 +81,6 @@ dependencies { androidTestImplementation 'io.mockk:mockk:1.13.2' androidTestImplementation 'de.mannodermaus.junit5:android-test-core:1.3.0' androidTestRuntimeOnly 'de.mannodermaus.junit5:android-test-runner:1.3.0' + // for context in instrumentation test + androidTestImplementation 'androidx.test:core:1.5.0' } diff --git a/app/src/androidTest/java/com/malibin/study/github/ExampleInstrumentedTest.kt b/app/src/androidTest/java/com/malibin/study/github/ExampleInstrumentedTest.kt index eba15b0..562464d 100644 --- a/app/src/androidTest/java/com/malibin/study/github/ExampleInstrumentedTest.kt +++ b/app/src/androidTest/java/com/malibin/study/github/ExampleInstrumentedTest.kt @@ -1,24 +1,21 @@ package com.malibin.study.github import androidx.test.platform.app.InstrumentationRegistry -import androidx.test.ext.junit.runners.AndroidJUnit4 - +import org.junit.Assert.assertEquals import org.junit.Test -import org.junit.runner.RunWith - -import org.junit.Assert.* /** * Instrumented test, which will execute on an Android device. * * See [testing documentation](http://d.android.com/tools/testing). */ -@RunWith(AndroidJUnit4::class) + class ExampleInstrumentedTest { @Test - fun useAppContext() { - // Context of the app under test. - val appContext = InstrumentationRegistry.getInstrumentation().targetContext - assertEquals("com.malibin.study.github", appContext.packageName) + fun `올바른_패키지_명을_반환한다`() { + //when + val actualResult = InstrumentationRegistry.getInstrumentation().targetContext + //then + assertEquals("com.malibin.study.github", actualResult.packageName) } } diff --git a/app/src/test/java/com/malibin/study/github/data/repository/DefaultGithubProfileRepositoryTest.kt b/app/src/test/java/com/malibin/study/github/data/repository/DefaultGithubProfileRepositoryTest.kt index 4bf8e8a..a533b87 100644 --- a/app/src/test/java/com/malibin/study/github/data/repository/DefaultGithubProfileRepositoryTest.kt +++ b/app/src/test/java/com/malibin/study/github/data/repository/DefaultGithubProfileRepositoryTest.kt @@ -93,7 +93,7 @@ internal class DefaultGithubProfileRepositoryTest { val actualResult = defaultGithubProfileRepository.getGithubProfile("name1") //then assertAll( - { assertThat(actualResult).isEqualTo(Result.success(gitHubProfile))}, + { assertThat(actualResult.getOrNull()).isEqualTo(gitHubProfile)}, { coVerify(exactly = 1) { fakeLocalGithubProfileSource.getGithubProfile("name1") } } ) }