Skip to content
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

Step3 미션 제출합니다. #7

Open
wants to merge 4 commits into
base: Larry7939
Choose a base branch
from
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,7 @@

## 🎲 2단계
1. loadGithubProfile 메소드 호출 성공 시 GithubProfile을 가져온다.
2. loadGithubProfile 메소드 호출 실패 시 isError의 value 가 True가 된다.
2. loadGithubProfile 메소드 호출 실패 시 isError의 value 가 True가 된다.

## 🎲 3단계
1. 올바른 패키지 명을 반환한다.
4 changes: 4 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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'
}
Original file line number Diff line number Diff line change
@@ -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
Comment on lines 5 to -7
Copy link
Member

Choose a reason for hiding this comment

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

org.junit.Test 는 Junit4이에요.
Junit5를 활용해서 테스트를 구성해주세요 :)


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
Comment on lines +16 to +17
Copy link
Member

Choose a reason for hiding this comment

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

ApplicationProvider.getApplicationContext() 를 활용해볼 수 있어요 😊

//then
assertEquals("com.malibin.study.github", actualResult.packageName)
}
Comment on lines +19 to 20
Copy link
Member

Choose a reason for hiding this comment

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

이 부분도 Truth를 활용해서 테스트를 검증해보세요 :)

}
Original file line number Diff line number Diff line change
Expand Up @@ -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") } }
)
}
Expand Down