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

[둘리] 1단계 자동 DI 미션 제출합니다 #5

Merged
merged 18 commits into from
Sep 5, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test: CartActivityTest 추가
  • Loading branch information
hyemdooly committed Sep 5, 2023
commit abb51862f45b7c0e6e8f2965d667abaa44df2497
44 changes: 44 additions & 0 deletions app/src/test/java/woowacourse/shopping/CartActivityTest.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package woowacourse.shopping

import androidx.arch.core.executor.testing.InstantTaskExecutorRule
import androidx.lifecycle.ViewModelProvider
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import woowacourse.shopping.ui.cart.CartActivity
import woowacourse.shopping.ui.cart.CartViewModel

@RunWith(RobolectricTestRunner::class)
class CartActivityTest {

@get:Rule
var instantTaskExecutorRule = InstantTaskExecutorRule() // AAC 컴포넌트들을 한 스레드에서 실행되도록 함

@Test
fun `Activity 실행 테스트`() {
// given
val activity = Robolectric
.buildActivity(CartActivity::class.java)
.create()
.get()

// then
assertThat(activity).isNotNull()
}

@Test
fun `ViewModel 주입 테스트`() {
// given
val activity = Robolectric
.buildActivity(CartActivity::class.java)
.create()
.get()
val viewModel = ViewModelProvider(activity)[CartViewModel::class.java]

// then
assertThat(viewModel).isNotNull()
}
}