File tree Expand file tree Collapse file tree 4 files changed +42
-0
lines changed
src/test/java/com/example/android/architecture/blueprints/todoapp Expand file tree Collapse file tree 4 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,14 @@ apply plugin: "androidx.navigation.safeargs.kotlin"
6
6
android {
7
7
compileSdkVersion rootProject. compileSdkVersion
8
8
9
+ /**
10
+ * Allows to access Android Resources in your unit tests, including AndroidManifest file.
11
+ * This will resolve "no such as manifest file: " warning.
12
+ */
13
+ testOptions. unitTests {
14
+ includeAndroidResources = true
15
+ }
16
+
9
17
defaultConfig {
10
18
applicationId " com.example.android.architecture.blueprints.reactive"
11
19
minSdkVersion rootProject. minSdkVersion
@@ -54,6 +62,11 @@ dependencies {
54
62
testImplementation " junit:junit:$junitVersion "
55
63
testImplementation " com.google.truth:truth:1.1.2"
56
64
65
+ // AndroidX Test - JVM testing
66
+ testImplementation " androidx.test.ext:junit-ktx:$androidXTestExtKotlinRunnerVersion "
67
+ testImplementation " androidx.test:core-ktx:$androidXTestCoreVersion "
68
+ testImplementation " org.robolectric:robolectric:$robolectricVersion "
69
+
57
70
// AndroidX Test - Instrumented testing
58
71
androidTestImplementation " androidx.test.ext:junit:$androidXTestExtKotlinRunnerVersion "
59
72
androidTestImplementation " androidx.test.espresso:espresso-core:$espressoVersion "
Original file line number Diff line number Diff line change @@ -3,8 +3,11 @@ package com.example.android.architecture.blueprints.todoapp.statistics
3
3
import com.example.android.architecture.blueprints.todoapp.data.Task
4
4
import com.google.common.truth.Truth
5
5
import org.junit.Test
6
+ import org.junit.runner.RunWith
7
+ import org.junit.runners.JUnit4
6
8
7
9
10
+ @RunWith(JUnit4 ::class )
8
11
internal class StatisticsUtilsTest {
9
12
10
13
Original file line number Diff line number Diff line change
1
+ package com.example.android.architecture.blueprints.todoapp.tasks
2
+
3
+ import androidx.test.core.app.ApplicationProvider
4
+ import androidx.test.ext.junit.runners.AndroidJUnit4
5
+ import org.junit.Test
6
+ import org.junit.runner.RunWith
7
+
8
+
9
+ @RunWith(AndroidJUnit4 ::class )
10
+ internal class TasksViewModelTest {
11
+
12
+ @Test
13
+ fun addNewTask_setNewTask () {
14
+
15
+ // Assign a ViewModel
16
+ val tasksViewModel = TasksViewModel (ApplicationProvider .getApplicationContext())
17
+
18
+ // Assert adding a new Task
19
+ tasksViewModel.addNewTask()
20
+
21
+ // Act new Task is added
22
+ // TODO: Test live data.
23
+ }
24
+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ buildscript {
5
5
google()
6
6
mavenCentral()
7
7
}
8
+
8
9
dependencies {
9
10
classpath ' com.android.tools.build:gradle:7.0.3'
10
11
classpath " org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion "
46
47
recyclerViewVersion = ' 1.2.1'
47
48
roomVersion = ' 2.3.0'
48
49
rulesVersion = ' 1.0.1'
50
+ robolectricVersion = ' 4.10.3'
49
51
swipeRefreshLayoutVersion = ' 1.1.0'
50
52
timberVersion = ' 4.7.1'
51
53
}
You can’t perform that action at this time.
0 commit comments