Skip to content

Commit

Permalink
Merge branch 'an/develop' into an/fix/pokemon-evolution-navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
sh1mj1 committed Dec 15, 2024
2 parents 2305509 + a289e42 commit afe23cc
Show file tree
Hide file tree
Showing 19 changed files with 463 additions and 203 deletions.
9 changes: 6 additions & 3 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ dependencies {
implementation(libs.glide)
kapt(libs.glide.compiler)
implementation(libs.splash.screen)
implementation(libs.balloon)
// google & firebase
implementation(platform(libs.firebase.bom))
implementation(libs.firebase.crashlytics.buildtools)
Expand All @@ -170,13 +171,15 @@ dependencies {
implementation(platform(libs.koin.bom))
implementation(libs.koin.android)
androidTestImplementation(libs.koin.android.test)
// unit test
testRuntimeOnly(libs.junit.vintage.engine)
// robolectric test
testImplementation(libs.robolectric)
testImplementation(libs.bundles.android.test)
// android test
androidTestImplementation(libs.bundles.android.test)
debugImplementation(libs.bundles.android.test)
testRuntimeOnly(libs.junit.vintage.engine)
androidTestRuntimeOnly(libs.junit5.android.test.runner)
testImplementation(libs.android.test.fragment)
debugImplementation(libs.android.test.fragment.manifest)

implementation(libs.balloon)
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import io.kotest.matchers.string.shouldContain
import org.junit.Test
import org.junit.runner.RunWith
import poke.rogue.helper.presentation.util.testContext
import poke.rogue.helper.testing.testContext

@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
package poke.rogue.helper.presentation.dex

import androidx.lifecycle.lifecycleScope
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.IdlingRegistry
import androidx.test.espresso.IdlingResource
import androidx.test.espresso.action.ViewActions
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import io.kotest.matchers.nulls.shouldNotBeNull
import org.hamcrest.CoreMatchers.not
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.androidx.viewmodel.ext.android.getViewModel
import poke.rogue.helper.R
import poke.rogue.helper.presentation.di.testViewModelModule
import poke.rogue.helper.testing.idleresource.asIdlingResource
import poke.rogue.helper.testing.rule.KoinAndroidUnitTestRule
import poke.rogue.helper.testing.view.withItemCount

@RunWith(AndroidJUnit4::class)
class PokemonListActivityTest {
@get:Rule
val activityRule = activityScenarioRule<PokemonListActivity>()
val scenario get() = activityRule.scenario
private lateinit var idlingResource: IdlingResource

@get:Rule
val koinTestRule =
KoinAndroidUnitTestRule(
testViewModelModule,
)

@Before
fun setUp() {
scenario.onActivity { activity ->
val viewModel = activity.getViewModel<PokemonListViewModel>()

// StateFlow의 값이 비어 있지 않은 상태를 Idle로 간주
idlingResource =
viewModel.uiState.asIdlingResource(activity.lifecycleScope) { uiState ->
uiState.pokemons.isNotEmpty()
}

// IdlingResource 등록
IdlingRegistry.getInstance().register(idlingResource)
}
}

@After
fun tearDown() {
IdlingRegistry.getInstance().unregister(idlingResource)
}

@Test
fun `Activity_실행_테스트`() {
scenario.onActivity { activity ->
activity.shouldNotBeNull()
}
}

@Test
fun `포켓몬_리스트가_화면에_보인다`() {
onView(withId(R.id.rv_pokemon_list))
.check(matches(isDisplayed()))
}

@Test
fun `포켓몬_리스트_아이템_카운트_테스트`() {
onView(withId(R.id.rv_pokemon_list))
.check(withItemCount(10))
}

@Test
fun `스크롤_down_시_헤더_그룹이_사라지고_스크롤_up_시_헤더_그룹이_보인다`() {
// scroll down
onView(withId(R.id.root_pokemon_list))
.perform(ViewActions.swipeUp())
onView(withId(R.id.header_group))
.check(matches(not(isDisplayed())))
// scroll up
onView(withId(R.id.root_pokemon_list))
.perform(ViewActions.swipeDown())
onView(withId(R.id.header_group))
.check(matches(isDisplayed()))
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package poke.rogue.helper.presentation.di

import org.koin.core.module.dsl.singleOf
import org.koin.core.module.dsl.viewModel
import org.koin.core.module.dsl.viewModelOf
import org.koin.dsl.module
import poke.rogue.helper.presentation.ability.AbilityViewModel
import poke.rogue.helper.presentation.ability.detail.AbilityDetailViewModel
import poke.rogue.helper.presentation.battle.BattleViewModel
import poke.rogue.helper.presentation.battle.selection.BattleSelectionViewModel
import poke.rogue.helper.presentation.battle.selection.pokemon.PokemonSelectionViewModel
import poke.rogue.helper.presentation.battle.selection.skill.SkillSelectionViewModel
import poke.rogue.helper.presentation.biome.BiomeViewModel
import poke.rogue.helper.presentation.biome.detail.BiomeDetailViewModel
import poke.rogue.helper.presentation.dex.PokemonListViewModel
import poke.rogue.helper.presentation.dex.detail.PokemonDetailViewModel
import poke.rogue.helper.presentation.home.HomeViewModel
import poke.rogue.helper.presentation.type.TypeViewModel
import poke.rogue.helper.testing.di.testingModule

val testViewModelModule =
module {
includes(testingModule)

singleOf(::PokemonListViewModel)
singleOf(::HomeViewModel)
singleOf(::AbilityViewModel)
singleOf(::AbilityDetailViewModel)
viewModelOf(::TypeViewModel)
viewModel<BattleViewModel> { params ->
BattleViewModel(get(), get(), get(), params.getOrNull(), params.getOrNull())
}
viewModel<BattleSelectionViewModel> { params ->
BattleSelectionViewModel(params.get(), params.get(), get())
}
viewModel { params ->
PokemonSelectionViewModel(get(), params.getOrNull(), get())
}
viewModel { params ->
SkillSelectionViewModel(get(), params.getOrNull(), get())
}
singleOf(::BiomeViewModel)
singleOf(::BiomeDetailViewModel)
singleOf(::PokemonDetailViewModel)
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ import org.junit.Test
import org.junit.jupiter.api.DisplayName
import org.junit.runner.RunWith
import poke.rogue.helper.R
import poke.rogue.helper.presentation.di.testViewModelModule
import poke.rogue.helper.testing.rule.KoinAndroidUnitTestRule

@RunWith(AndroidJUnit4::class)
class HomeActivityTest {
@get:Rule
val activityRule = ActivityScenarioRule(HomeActivity::class.java)

@get:Rule
val koinTestRule =
KoinAndroidUnitTestRule(
testViewModelModule,
)

@Test
@DisplayName("앱이 실행되면 포켓로그 로고가 보인다")
fun test1() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,20 @@ import org.junit.Test
import org.junit.jupiter.api.DisplayName
import org.junit.runner.RunWith
import poke.rogue.helper.R
import poke.rogue.helper.presentation.di.testViewModelModule
import poke.rogue.helper.testing.rule.KoinAndroidUnitTestRule

@RunWith(AndroidJUnit4::class)
class TypeActivityTest {
@get:Rule
val activityRule = ActivityScenarioRule(TypeActivity::class.java)

@get:Rule
val koinTestRule =
KoinAndroidUnitTestRule(
testViewModelModule,
)

@Test
@DisplayName("사용자가 아무것도 선택하지 않은 경우에는 선택 안내 이미지가 보인다")
fun test1() {
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package poke.rogue.helper.presentation.battle

import WeatherSpinnerAdapter
import android.app.Activity
import android.content.Context
import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
package poke.rogue.helper.presentation.battle

import android.content.Context
import android.view.LayoutInflater
import android.view.View
Expand Down
Loading

0 comments on commit afe23cc

Please sign in to comment.