Skip to content

Commit 16a8ca3

Browse files
committed
add ToDoListItemViewModelTest & comment out
1 parent 764c452 commit 16a8ca3

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

app/build.gradle

+6
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ android {
4949
unitTests {
5050
includeAndroidResources = true
5151
}
52+
53+
unitTests.all {
54+
testLogging {
55+
events 'started', 'passed', 'skipped', 'failed'
56+
}
57+
}
5258
}
5359
}
5460

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package io.github.mrtry.todolist.app.todo.viewmodel
2+
3+
// TODO:
4+
// テストしたかったが、RobolectricTestRunnerのテストを走らせるとなぜかテストが終わらない
5+
// 一旦コメントアウトする
6+
7+
//@RunWith(RobolectricTestRunner::class)
8+
//class ToDoListItemViewModelTest {
9+
// @Rule
10+
// @JvmField
11+
// val rule: TestRule = InstantTaskExecutorRule()
12+
//
13+
// private lateinit var viewModel: ToDoListItemViewModel
14+
//
15+
// private lateinit var mockNavigator: ToDoNavigator
16+
// private lateinit var mockDomainService: ToDoDomainService
17+
//
18+
// @Before
19+
// fun setUp() {
20+
// mockNavigator = mock()
21+
// mockDomainService = mock()
22+
//
23+
// viewModel = ToDoListItemViewModel(
24+
// ToDo(),
25+
// mock(),
26+
// mockNavigator,
27+
// mockDomainService,
28+
// TestCoroutineScope()
29+
// )
30+
// }
31+
//
32+
// @Test
33+
// fun checkIsComplete_fail() = runBlockingTest {
34+
// val beforeValue = viewModel.isComplete.requireValue()
35+
// whenever(mockDomainService.saveToRepository(any())).thenThrow(IllegalStateException())
36+
//
37+
// viewModel.isComplete.value = !beforeValue
38+
//
39+
// verify(mockNavigator, times(1)).showSnackBar(any(), any())
40+
// assertThat(viewModel.isComplete.requireValue()).isEqualTo(beforeValue)
41+
// }
42+
//}

0 commit comments

Comments
 (0)